Child routes in vue-router return

the route is written as follows

routes: [
    
    { path: "/A", component: A },
    { path: "/B", 
        component: B ,
        children: [
            { path: "", component: B1},
            { path: "b2", component: B2},
            { path: "b3", component: B3},
        ]
    },
  ]
  
  

when I enter component B from component A, then enter component B2 from B1, and then enter B3, I expect that regardless of B1MagB2JOB3, I can click back to return to the A page, instead of returning to B2 from B3 (in fact, I hope that when I click back, I can skip the child route directly and directly take the outer route as the unit)

I don"t know how to implement

Mar.09,2021

when you use $router.push (), a record is added to the history,

solution: use router.replace , much like router.push, except that instead of adding a new record to history, it does the same as its method name-replacing the current history record.

the outer route enters the child route using router.replace instead of router.push.

vue-router has a description on the official website

  • How can vue-router listen for return events

    how can the return event of vue-router be monitored? is there any other way to listen to the history event with the original sound? what is the difference between the return button in the browser and the return in Wechat? I wonder if the return in Wec...

    Mar.09,2021
Menu