路由守卫内加判断条件报错
来源:9-2 路由守卫实现基础登陆校验功能

慕数据2448395
2021-04-12
路由守卫内加判断条件报错
router.beforeEach((to, from, next) => {
const isLogin = localStorage.isLogin
if (isLogin || to.name === ‘Login’) {
next()
} else {
next({ name: ‘Login’ })
}
console.log(to, from, next)
next()
})
上面那么写会报下面的错误:
Failed to compile.
./src/router/index.js
Module not found: Error: Can’t resolve ‘core-js/modules/es.function.name.js’ in ‘C:\Users\ZS\Desktop\jingdong\src\router’
不写里面的判断条件正常运行:
router.beforeEach((to, from, next) => {
console.log(to, from, next)
next()
})
写回答
1回答
-
Dell
2021-04-12
你再下面的正常运行的代码里加一个 if(true) {console.log(123)} 能执行吗?
062021-04-17