当要求用户登录才可操作,但是没有登录的时候,路由设置

 1 router.beforeEach((to, from, next) => {
 2   const auth = router.app.$options.store.state.auth
 3 
 4   if (
 5     (auth && to.path.indexOf('/auth/') !== -1) ||
 6     (!auth && to.meta.auth)
 7   ) {
 8     next('/')
 9   } else {
10     next()
11   }
12 })

跳转到首页

原文地址:https://www.cnblogs.com/yangguoe/p/9317175.html