修改封装删除路由并重新push
This commit is contained in:
@@ -121,7 +121,7 @@
|
||||
import 'moment/locale/zh-cn'
|
||||
import { generateIndexRouter } from '@/utils/util'
|
||||
import store from '../../store'
|
||||
import router from '../../router'
|
||||
import router,{resetRouter} from '../../router'
|
||||
|
||||
moment.locale('zh-cn')
|
||||
const EN = 'en-us'
|
||||
@@ -303,6 +303,11 @@
|
||||
break
|
||||
}
|
||||
store.dispatch('GetPermissionList').then(res => {
|
||||
const menuData = res.result.menu;
|
||||
resetRouter()
|
||||
let constRoutes = [];
|
||||
constRoutes = generateIndexRouter(menuData);
|
||||
router.addRoutes(constRoutes)
|
||||
this.$root.Bus.$emit('switchLanguage', localeval)
|
||||
this.isLoading = false
|
||||
this.localeval = localeval
|
||||
|
||||
@@ -6,6 +6,7 @@ import App from './App.vue'
|
||||
import Storage from 'vue-ls'
|
||||
import router from './router'
|
||||
import store from './store/'
|
||||
|
||||
import $ from 'jquery'
|
||||
import {
|
||||
VueAxios
|
||||
|
||||
@@ -10,9 +10,15 @@ Router.prototype.push = function push(location, onResolve, onReject) {
|
||||
return originalPush.call(this, location).catch(err => err)
|
||||
}
|
||||
|
||||
export default new Router({
|
||||
const createRouter = ()=> new Router({
|
||||
mode: 'history',
|
||||
base: process.env.BASE_URL,
|
||||
scrollBehavior: () => ({ y: 0 }),
|
||||
routes: constantRouterMap
|
||||
})
|
||||
})
|
||||
const router = createRouter()
|
||||
export function resetRouter () {
|
||||
const newRouter = createRouter()
|
||||
router.matcher = newRouter.matcher // reset router
|
||||
}
|
||||
export default router
|
||||
Reference in New Issue
Block a user