Преглед на файлове

优化:改写弃用的方法router.addRoutes

萤火科技 преди 3 години
родител
ревизия
d785579b13
променени са 1 файла, в които са добавени 4 реда и са изтрити 1 реда
  1. 4 1
      src/permission.js

+ 4 - 1
src/permission.js

@@ -49,7 +49,10 @@ router.beforeEach((to, from, next) => {
             store.dispatch('GenerateRoutes', { roles })
               .then(routers => {
                 // 动态添加可访问路由表
-                router.addRoutes(routers)
+                // router.addRoutes(routers)
+                for (const x of routers) {
+                  router.addRoute(x)
+                }
                 // 请求带有 redirect 重定向时,登录自动重定向到该地址
                 const redirect = decodeURIComponent(from.query.redirect || to.path)
                 if (to.path === redirect) {