router in the meta

meta field (metadata)
when routing configuration, routing added directly to each custom object meta, meta object may be provided in some of the state, to do something.
For example: login authentication
{
path: '/ actile',
name: 'Actile',
Component: Actile,
Meta: {
login_require: to false
},
},
{
path: '/ goodslist',
name: 'goodslist',
Component: Goodslist,
Meta: {
login_require: to true
},
Children: [
{
path: 'Online',
Component: GoodslistOnline
}
]
}
can be used as such in the navigation guard
router.beforeEach ((to, from, Next) => {
IF (to.matched .some (function (Item) {
return item.meta.login_require
})) {
Next ( '/ Login')
} the else
Next ()
})
requires only the following judgment item meta object login_require is not true, can do some limit.

Original article reprint: https://blog.csdn.net/cofecode/article/details/79181894

Guess you like

Origin www.cnblogs.com/yangguanglei/p/12190914.html