fe-interview
fe-interview copied to clipboard
[vue] vur-router怎么重定向?
[vue] vur-router怎么重定向?
{ path:'/goback', redirect:'/' }
路径:{ path: '/a', redirect: '/b' }
命名的路由: { path: '/a', redirect: {name:'/foo'} }
动态重定向目标: { path: '/a', redirect: to => {
const {
query,
params,
hash
} = to
if (params.name) {
return /${params.name}
} else if (query.to && query.to === "bar") {
return /${query.to}
} else if (hash === '#baz') {
return '/baz'
}
}
}
path:"" 或者redirect:"地址"