Uncaught TypeError: Cannot read properties of undefined (reading ‘beforeEach‘)
问题描述运行项目页面一片空白,报错原因和解决方案:router.beforeEach写在定义router之后代码const router = new VueRouter({mode: 'history',base: process.env.BASE_URL,routes})router.beforeEach((to, from, next) => {if (to.path !== '/nul
·
问题描述
运行项目页面一片空白,报错

原因和解决方案:
router.beforeEach写在定义router之后
代码
const router = new VueRouter({
mode: 'history',
base: process.env.BASE_URL,
routes
})
router.beforeEach((to, from, next) => {
if (to.path !== '/null') {
if (localStorage.getItem("token")) {
next()
} else {
next("/null")
}
} else {
next()
}
})
更多推荐



所有评论(0)