import Vue from 'vue' import Router from 'uni-simple-router' Vue.use(Router) //初始化 const router = new Router({ APP: { animation: { animationType: 'pop-in', animationDuration: 300 } }, encodeURI: true, routes: ROUTES //路由表 }); //全局路由前置守卫 router.beforeEach((to, from, next) => { console.log('to',to) console.log('----willGo----',to.path) // 有两个个判断条件,一个是token,还有一个路由元信息 if(to.path!='/pages/login/login'){ uni.setStorageSync('fromLogin',{path: to.path,query: to.query}) } if (to.meta && to.meta.auth) { console.log('我要登录'); // next('/pages/login/login'); next(); } else { console.log('正常跳转页面'); next(); } }) // 全局路由后置守卫 router.afterEach((to, from) => { }) export default router;