Browse Source

修改路由全局报错

zhuxinbo 5 years ago
parent
commit
2c01260ad7

+ 1 - 1
src/components/layouts/TabLayout.vue

@@ -136,7 +136,7 @@
           this.menuVisible = true
         }
       },
-      getPageKey(target, depth) {
+      getPageKey(target, depth) {n
         depth = depth || 0
         if (depth > 2) {
           return null

+ 4 - 1
src/components/page/GlobalLayout.vue

@@ -119,7 +119,10 @@
     created() {
       //--update-begin----author:scott---date:20190320------for:根据后台菜单配置,判断是否路由菜单字段,动态选择是否生成路由(为了支持参数URL菜单)------
       //this.menus = this.mainRouters.find((item) => item.path === '/').children;
-      this.menus = this.permissionMenuList
+      if(this.permissionMenuList){
+        this.menus = this.permissionMenuList
+      }
+      
       // 根据后台配置菜单,重新排序加载路由信息
       console.log('----加载菜单逻辑----')
       console.log(this.mainRouters)

+ 5 - 0
src/router/index.js

@@ -4,6 +4,11 @@ import {constantRouterMap} from '@/config/router.config'
 
 Vue.use(Router)
 
+const originalPush = Router.prototype.push;
+Router.prototype.push = function push(location) {
+  return originalPush.call(this, location).catch(err => err)
+}
+
 export default new Router({
   mode: 'history',
   base: process.env.BASE_URL,