【发布时间】:2021-02-16 09:25:05
【问题描述】:
我有 2 条路线
{
path: '/a/:aP1/:aP2/',
component: APage,
onEnter: (nextState, replace) => {
replace({
state: {
status: 301
},
pathname: `/b/${nextState.params.aP1}/${nextState.params.aP2}/`
});
}
},
{
path: '/b/:bP1/:bP2/',
component: BPage,
onEnter: (nextState, replace) => {
replace({
state: {
status: 301
},
pathname: `/a/${nextState.params.bP1}/${nextState.params.bP2}/`
});
}
}
问题是当我进行重定向时,它会将路径名附加到路由路径。所以不是这个重定向/a/p1/p2 我得到这个 - /b/a/p1/p2。如何解决这个问题?
【问题讨论】:
标签: reactjs redirect react-router