1.router.js

      {
		path: '/deliver', //发货
		component: (resolve) => require(['../components/pages/deliver'], resolve),
		meta: {
           requiresAuth:true,
           keepAlive: true,
			}
		},

2.main.js

router.beforeEach((to, from, next) => {
  if (to.meta.requiresAuth && !localStorage.getItem('uid')) {
    next({path: '/login'})
  } else {
    next()
  }
})

 

Logo

前往低代码交流专区

更多推荐