【问题标题】:Overwrite ManifestsMeta Data覆盖清单元数据
【发布时间】:2018-12-08 12:30:21
【问题描述】:

我有一个包含名称等内容的清单,它也会立即为我的页面显示元标记。现在我想在我的个人页面上使用元标签,问题是清单元标签不会被覆盖,这导致它们对 Facebook 等网站具有更高的优先级。

示例清单:

  manifest: {
    theme_color: '#1a1a1a',
    name: 'Stackoverflow',
    short_name: 'SO',
    description: 'Questions and Answers',
    lang: 'de'
  },

页面中的示例更改:

  head () {
    return {
      meta: [
        { name: 'og:url', content: 'www.notstackoverflow.com' },
        { name: 'og:type', content: 'article' },
        { name: 'og:title', content: this.post.titel },
        { name: 'og:description', content: this.post.subtitel },
      ]
    }
  },

问题在于它仍然使用清单而不是页面中的标题和描述。如果我继续查看源代码,它只会在清单之后添加页面中的那些。

(Nuxt + PWA 模块)

【问题讨论】:

    标签: vuejs2 manifest progressive-web-apps nuxt.js


    【解决方案1】:

    您必须为每个元添加 hid 属性:

     head () {
        return {
          meta: [
            { hid: 'og:url', name: 'og:url', content: 'www.notstackoverflow.com' },
            { hid: 'og:type', name: 'og:type', content: 'article' },
            { hid: 'og:title', name: 'og:title', content: this.post.titel },
            { hid: 'og:description', name: 'og:description', content: this.post.subtitel },
          ]
        }
      },
    

    https://nuxtjs.org/faq/duplicated-meta-tags

    为避免在子组件中使用时出现重复,请使用“hid”键提供唯一标识符。

    【讨论】:

    • 10 分钟前找到了完全相同的解决方案,仍然感谢您的回答,它是正确的。
    猜你喜欢
    • 1970-01-01
    • 2019-07-24
    • 2020-06-03
    • 1970-01-01
    • 1970-01-01
    • 2016-05-04
    • 1970-01-01
    • 1970-01-01
    • 2015-07-16
    相关资源
    最近更新 更多