index.js 920 B

1234567891011121314151617181920212223242526272829303132333435
  1. import Vue from 'vue'
  2. import Router from 'vue-router'
  3. // import Login from '@/pages/loginView/loginView.vue'
  4. import mainView from '@/pages/mainView/mainView.vue'
  5. Vue.use(Router)
  6. const router = new Router({
  7. // mode: 'history',
  8. routes: [
  9. // 页面初始化
  10. {
  11. path: '/',
  12. redirect: '/pages/mainView'
  13. },
  14. {
  15. path: '/pages/mainView',
  16. name: 'mainView',
  17. component: mainView
  18. }
  19. ],
  20. })
  21. router.beforeEach((to, from, next) => {
  22. console.warn("router:start-1", from,to);
  23. //如果存在用户账号信息|| to.query.uid
  24. next();
  25. })
  26. //同一个路由跳转报错解决,NavigationDuplicated: Avoided redundant navigation to current location:
  27. const originalPush = Router.prototype.push
  28. Router.prototype.push = function push(location) {
  29. return originalPush.call(this,location).catch(err=>err)
  30. }
  31. export default router;