vue使用动态添加路由,重置路由没有生效
使用的以下方法重置的路由
export function resetRouter () {
router.matcher = new Router({
mode: 'hash',
base: process.env.VUE_APP_PUBLICPATH,
scrollBehavior: () => ({
y: 0
}),
routes: [...constantRoutes]
}).matcher // reset router
}
可以参考我的解决方案:
https://gitee.com/ericfang/ea...
addRoutes
之后在重置matcher
即可;