我有一个关于VueJS及其身份验证形式的问题,我正在尝试使用beforeEnter执行多重身份验证保护,但它不起作用,我在想如何做的工作上工作,以查看他们是否可以帮帮我。
const isGlobal = (to, from, next) => {
console.log('isGlobal called');
if (store.getters.isAuthenticated && store.getters.getProfile.is_global) {
next();
return
}
next(false )
}
const isAdmin = (to, from, next) => {
console.log('isAdmin called');
if (store.getters.isAuthenticated && store.getters.getProfile.is_admin) {
next();
return
}
next(false)
}
const isSupervisor = (to, from, next) => {
console.log('isSupervisor called');
if (store.getters.isAuthenticated && store.getters.getProfile.is_supervisor) {
next();
return
}
next(false)
}
const routes = [{
path: '/',
name: 'login',
component: Login,
beforeEnter: [isSupervisor || isGlobal || isAdmin],
}
];
谢谢
答案 0 :(得分:0)
问题在于let all = [
{
horas: [
{
id_prof: 1,
inicial: "10:00",
final: "11:00"
}
],
id: 1,
date: "17-08-1993"
},
{
horas: [
{
id_prof: 2,
inicial: "12:00",
final: "13:00"
}
],
id: 2,
date: "18-08-1993"
},
{
horas: [
{
id_prof: 3,
inicial: "10:00",
final: "11:00"
}
],
id: 3,
date: "19-08-1993"
}
];
let events = all.map(x => ({id:x.id, date:x.date, inicial:x.horas[0].inicial, final:x.horas[0].final}))
console.log(events)
是一个等于[isSupervisor || isGlobal || isAdmin]
或[false]
的数组,它必须是一个函数。尝试这样的事情:
[true]