【发布时间】:2019-04-02 06:37:09
【问题描述】:
我的 vue 路线为
const ifAuthenticated = (to, from, next) => {
if (store.getters.isAuthenticated) {
next()
return
}
next('/login')
}
const checkAgentPermissions = () => {
return false
}
export const routes = [
{
path: '/users',
beforeEnter: ifAuthenticated,
component: Layout,
meta: { title: 'Agent Onboarding', icon: 'address-card' },
hidden: checkAgentPermissions,
children: [
{
path: '',
name: 'Users',
component: () => import('@/views/users/index.vue')
},
{
.....some more childrens
}
]
}
]
但是当通过函数调用时,隐藏总是正确的。 如果我将 checkAgentPermissions 中隐藏的选项更改为 false
hidden: false // works perfectly
为什么函数不返回 false,实际上我需要在 fn 中做一些检查,然后根据它返回 true/false。
对于每个路由,我通过检查 hidden 是否为真/假来在 vue 组件中呈现它们。
【问题讨论】:
标签: vue.js vue-router privacy