fa.route.js 852 B

12345678910111213141516171819202122232425262728293031
  1. import Vue from 'vue'
  2. //这里仅示范npm安装方式的引入,其它方式引入请看最上面【安装】部分
  3. import Router from 'uni-simple-router'
  4. Vue.use(Router)
  5. //初始化
  6. const router = new Router({
  7. APP: {
  8. animation: {
  9. animationType: 'pop-in',
  10. animationDuration: 300
  11. }
  12. },
  13. encodeURI:false,
  14. routes: ROUTES //路由表
  15. });
  16. //全局路由前置守卫
  17. router.beforeEach((to, from, next) => {
  18. //去的页面是登录类型,来的页面不是登录类型,就缓存此页面,排除用户协议
  19. if(to.path.indexOf('/login/') != -1 && from.path.indexOf('/login/') == -1 && from.path.indexOf('agreement') == -1){
  20. uni.setStorageSync('last_page', {path:from.path,query:from.query});
  21. }
  22. next();
  23. })
  24. // 全局路由后置守卫
  25. router.afterEach((to, from) => {
  26. // console.log('999', to, from)
  27. })
  28. export default router;