index.js 650 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. // 路由
  2. import {
  3. RouterMount,
  4. createRouter
  5. } from 'uni-simple-router';
  6. const router = createRouter({
  7. platform: process.env.VUE_APP_PLATFORM,
  8. applet: {
  9. animationDuration: 100 //默认 300ms
  10. },
  11. // 通配符,非定义页面,跳转404
  12. routes: [
  13. {
  14. path: '*',
  15. redirect: (to) => {
  16. return {
  17. name: '404'
  18. }
  19. }
  20. },
  21. ]
  22. });
  23. //全局路由前置守卫
  24. router.beforeEach((to, from, next) => {
  25. console.log('跳转结束')
  26. // 权限控制登录
  27. if (to.meta && to.meta.auth) {
  28. next(false);
  29. } else {
  30. next()
  31. }
  32. });
  33. router.afterEach((to, from) => {})
  34. export {
  35. router,
  36. RouterMount
  37. }