vue:在router里面给页面加title

Posted llqwm

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了vue:在router里面给页面加title相关的知识,希望对你有一定的参考价值。

vue中给组件页面加页面标题:
{
path: ‘/‘,
name: ‘index‘,
component: disconnect,
meta: { title: ‘首页‘ }
},
{
path: ‘/disconnect‘,
name: ‘disconnect‘,
component: disconnect,
meta: { title: ‘没有网络‘ }
},


然后再main.js
router.beforeEach((to, from, next) => {
window.document.title = to.meta.title;
next()
})

以上是关于vue:在router里面给页面加title的主要内容,如果未能解决你的问题,请参考以下文章

vue 在当前页面watch 里面 监听router,重复调用问题

vue-router,路由按需加载,页面加载完成后,this.$route 获取不到

vue路由跳转时更改页面title

为啥vue中子路由点击router-link只能刷新一次子页面?

Vue 如何返回页面时不重新发接口

vue里面的router-view标签是啥意思