nuxt.js 设置meta标签,动态设置title

妖狐艹你老母 2023-01-23 14:49 582阅读 0赞

全局设置meta在nuxt.config.js中
在nuxt.config.js配置文件中,有个head属性可以设置全局的title,content和keywords等属性

在这里插入图片描述

局部设置
设置某个单独页面的title和关键字等,首先要找到这个页面的JS代码有一个head()方法,同样可以进行一些类似的设置:

  1. <script> data() { return { title: this.$route.params.routers, }; }, head() { // 优化seo:动态设置title,keywords 和 description return { title: this.title, meta: [ { name: "keywords", content: "淘宝,西瓜视频,抖音,今日头条,懂球帝,微信,微博", }, // hid是一个唯一标识 { hid: 'description', name: 'names', content: '应用大全' }, ], }; }, }; </script>

发表评论

表情:
评论列表 (有 0 条评论,582人围观)

还没有评论,来说两句吧...

相关阅读