1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- // import carhelp from '@/utils/mixin.js'
- import Vue from 'vue'
- import uniCrazyRouter from "uni-crazy-router";
- Vue.use(uniCrazyRouter)
- //** 有bug, 第一次直接敲链接访问, 是访问bobo-router 前置守卫
- //** 后续操作,访问的是 uniCrazyRouter的前置守卫
- uniCrazyRouter.beforeEach(async (to, from, next) => {
- routerBeforeEach(to, from, next);
- })
- uniCrazyRouter.afterEach((to, from) => {
- // 逻辑代码
- var title = "优电联盟-电单车充电系统"
-
- console.log("afterEach")
- if (process.car.NODE_ENV == 'dev' || process.car.NODE_ENV == 'test') {
- title+= '(' + process.car.NODE_ENV + ')'
- }
- uni.setNavigationBarTitle({
- title: title ,
-
- })
- })
- uniCrazyRouter['on' + 'Error']((to, from) => {
- // 逻辑代码
- console.log("Error+start")
- console.log(to)
- console.log(from)
- console.log("Error+end")
- })
- import Router from './bobo-router'
- Vue.use(Router)
- // 路由配置 页面中全部使用this.$Router来操作路由,以实现路由的全局管理
- const router = new Router()
- // 路由全局拦截器 在这里处理登录、授权等相关操作
- router.beforeEach(function(to, from, next) {
- console.log('前置守卫')
- routerBeforeEach(to, from, next);
- })
- function routerBeforeEach(to, from, next) {
- next();
- }
- // 路由后置拦截器
- router.afterEach(function(to, from) {
- console.log('后置守卫')
- })
- // 路由跳转出错处理
- router.onError(function(e) {
- console.log('错误:', e.message || '路由跳转失败')
- })
- export default router
|