| 1234567891011121314151617181920212223242526272829303132333435 |
- import Vue from 'vue'
- import Router from 'vue-router'
- // import Login from '@/pages/loginView/loginView.vue'
- import mainView from '@/pages/mainView/mainView.vue'
- Vue.use(Router)
- const router = new Router({
- // mode: 'history',
- routes: [
- // 页面初始化
- {
- path: '/',
- redirect: '/pages/mainView'
- },
- {
- path: '/pages/mainView',
- name: 'mainView',
- component: mainView
- }
- ],
- })
- router.beforeEach((to, from, next) => {
- console.warn("router:start-1", from,to);
- //如果存在用户账号信息|| to.query.uid
- next();
- })
- //同一个路由跳转报错解决,NavigationDuplicated: Avoided redundant navigation to current location:
- const originalPush = Router.prototype.push
- Router.prototype.push = function push(location) {
- return originalPush.call(this,location).catch(err=>err)
- }
- export default router;
|