Login successfully dynamic routing router.addRoutes is normal, but F5 refresh, always blank screen, read a lot of materials, login successfully saved the permission list in sessionStorage TOTAL, how to solve
in app.vue
if (Cookies.get("SIGN")) {
this.$router.options.routes.push(JSON.parse(sessionStorage.getItem("TOTAL")))
this.$router.addRoutes(JSON.parse(sessionStorage.getItem("TOTAL")))
}
two kinds do not work
in main.js
router.onReady(() => {
if (sessionStorage.getItem("TOTAL")) {
router.options.routes.push(JSON.parse(sessionStorage.getItem("TOTAL")))
router.addRoutes(JSON.parse(sessionStorage.getItem("TOTAL")))
}
})
nor
in router/index.js
router.beforeEach((to, from, next) => {
router.options.routes.push(JSON.parse(sessionStorage.getItem("TOTAL")))
router.addRoutes(JSON.parse(sessionStorage.getItem("TOTAL")))
})
can"t do it either