【发布时间】:2018-09-12 02:19:21
【问题描述】:
我在vue-router 中提供了元数据,但它没有在我的 html 中返回
代码
router sample
{
path: '/',
name: 'home',
component: Home,
meta: {
title: 'Home Page - Welcome',
metaTags: [
{
name: 'description',
content: 'The home page of our example app.'
},
{
property: 'og:description',
content: 'The home page of our example app.'
}
]
}
},
{
path: '/login',
name: 'login',
component: Login,
meta: { title: 'Login' }
},
beforeeach
router.beforeEach((to, from, next) => {
if (to.matched.some(record => record.meta.requiresAuth)) {
if (localStorage.getItem('myApp.jwt') == null) {
next({
path: '/login',
params: { nextUrl: to.fullPath }
})
} else {
let user = JSON.parse(localStorage.getItem('myApp.user'))
if (to.matched.some(record => record.meta.is_admin)) {
if (user.is_admin == 1) {
next()
}
else {
next({ name: 'userboard' })
}
}
next()
}
} else {
next()
}
});
这是我的页面标题的样子:
并且浏览器中也没有元标记:
问题
- 如何解决此问题?
- 如何获取动态页面(如单个帖子组件)的标题?
.......
【问题讨论】: