1. 修改index.html
将TDK的内容清空,然后看到官方提到了位置的问题,meta标签必须写在头部head标签之内,而keywords的meta标签要写在title的meta标签之后,但又在description的meta标签之前,像下面这样的顺序写:
2. 来到路由配置中添加meta属性
meta: {
title: ‘首页’,
content: {
keywords: ‘关键字1,关键字2’,
description: ‘描述内容描述内容描述内容描述内容描述内容描述内容描述内容’
}
}
3. 找到Vue项目中的导航守卫
根据自己项目中导航守卫设置的位置,此处为了方便我就直接设置在了route.js中了
router.beforeEach((to, from, next) => {
// 路由发生变化改变description和keyword
if (to.meta.content