美文网首页
quasar seo插件

quasar seo插件

作者: 中v中 | 来源:发表于2021-03-30 18:36 被阅读0次
  1. quasar.conf.js framwork节点加入插件
plugins: [
        'Meta'
      ]
  1. 删除模版里的title,description,keywords节点

  2. 每个vue页面追加meta属性

<script>
// 一些.vue文件
export default {
  data () {
    return {
      title: 'Some title' // 我们定义"title"属性
    }
  },

  // 注意meta是此处的函数,
  // 是您从Vue组件的作用域引用属性的方式
  meta () {
    return {
      // 这将访问data“数据”中的“title”属性;
      // 每当“title”属性更改时,您的meta将自动更新
      title: this.title,
      meta: {
        description: { name: 'description', content: this.title + "description" },
        keywords: { name: 'keywords', content: this.title + "keywords" },
      }
    }
  },

  methods: {
    setAnotherTitle () {
      this.title = 'Another title' // 由于绑定,将自动触发meta更新
    }
  }
  // ...
}
</script>
  1. 页面源文件结果:


    图片.png
  2. 注意:
    需要在SSR模式下SEO才有用

相关文章

网友评论

      本文标题:quasar seo插件

      本文链接:https://www.haomeiwen.com/subject/zubghltx.html