https://www.jianshu.com/p/26c756097290
router导航守卫
// 假设我从A页面 -> B页面 -> C 页面,如果我按回退按钮的话,我想回到A页面,而不是正常的回退到B页面,该怎么实现呢?
export default new Router({ routes: [ { path: '/', component: a }, { path: '/a', component: a }, { path: '/b', component: b, beforeEnter:(to, from, next) => { from.path == '/c' ? next('/') :next(); } //beforeEnter 在进入这个路由之前,先判断是从哪个路由跳转的 }, { path: '/c', component: c } ]})
作者:刈懋
链接:https://www.jianshu.com/p/26c756097290
來源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。