Vue.js路由器仅从导航而不是从URL

时间:2019-02-11 09:07:09

标签: vue.js

如何解决vuejs-中的此错误 index.js?3672:101未捕获的TypeError:无法读取未定义的属性'beforeEach'

1 个答案:

答案 0 :(得分:0)

import VueRouter from 'vue-router';

Vue.use(VueRouter);
Vue.use(Router);
export default new Router({
   // history:true,
  routes: [
    {
      path: '/',
      name: 'HelloWorld',
      component: HelloWorld
    },
 {
      path: '/Dashboard/dashboard',
      name: 'Business Intelligence Platform',
      beforeEnter: requireAuth,
      component: dashboard
    },
export function requireAuth(to, from, next) {
  if (!formSubmit()) {
    next({
      path: '/',
      query: { redirect: to.fullPath }
    });
  } else {
    next();
  }
}