前端面试秘籍:https://github.com/yisainan/web-interview 欢迎star
1.如果执行一次,在main.js中写;
2.如果根据路由动态改变,在路由拦截
router.beforeEach((to, from, next) => {}中写;
代码:
document.title = 接口获取的title || '默认title'
document.querySelector('meta[name="keywords"]').setAttribute('content', 接口获取的keywords) document.querySelector('meta[name="description"]').setAttribute('content', 接口获取的description)