Vue-router initialization, routes fetches data from sessionStorage, but cannot record it

let constantRouter = sessionStorage.getItem("TOTAL")?JSON.parse(sessionStorage.getItem("TOTAL")):[
    {
        path: "/login",
        name: "login",
        component: login
    },
    {
        path: "/",
        name: "defaultLogin",
        component: login
    }
]

const router = new Router({
    linkActiveClass: "active",
    routes: constantRouter
})

so that new Router cannot load the data of sessionStorage

Oct.23,2021

  1. I don't know what your requirements are, but the design itself is unreasonable.
  2. sessionStorage should the name of the route be stored or some other unique identity? And sessionStorage closes the browser window or the tab is gone, is it just to refresh that?
  3. I don't know what the data you pulled out
Menu