原帖链接:http://www.hzhcontrols.com/new-1753116.html
折磨了我一下午,终于有一个是有用的了
在permission中写添加路由的方法然后导出
export const initRouter = async () => {
const res = await store.dispatch("permission/generateRoutes")
res.forEach((route: any) => {
router.addRoute(route)
})
}
之后在main.ts中引入使用
const boot = async () => {
await initRouter()
app.use(router).use(store).use(Directives).mount("#app")
}
boot()