router.js
var router = new Router({
routes: [{
path: '/landing/:code',
redirect: '/order/newOrders'
}]
})
router.beforeEach((to, from, next) => {
// 如何在这里获取到code值
})
当访问http://xxx.xxx.com/landing/fs... 路由会跳转到http://xxx.xxx.com/order/newO...,此时在beforeEach里获取到的to对象就是的params就没有code的值了 请问如何保留code值
在from里获取试试
每个钩子方法接收三个参数:
to: Route: 即将要进入的目标 路由对象
from: Route: 当前导航正要离开的路由