1. 程式人生 > >vue:在router裏面給頁面加title

vue:在router裏面給頁面加title

meta vue pat 標題 win itl con 組件 In

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