全局设置meta在nuxt.config.js中
在nuxt.config.js配置文件中,有个head属性可以设置全局的title,content和keywords等属性
局部设置
设置某个单独页面的title和关键字等,首先要找到这个页面的JS代码有一个head()方法,同样可以进行一些类似的设置:
<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>