Javascript 在动态路由更改的情况下,历史推送url不会重新初始化组件
我有一个路由定义为Javascript 在动态路由更改的情况下,历史推送url不会重新初始化组件,javascript,reactjs,Javascript,Reactjs,我有一个路由定义为/:business\u id/:branch\u id/user。当我使用history.push('/1/2/user')将url从/1/1/user更改为/1/2/user时,不会重新呈现组件 handleChange(val) { const { history, route: { match: { path, params: { business_id, tabKey, mode }}}} = this.context.router; let url =
/:business\u id/:branch\u id/user
。当我使用history.push('/1/2/user')
将url从/1/1/user
更改为/1/2/user
时,不会重新呈现组件
handleChange(val) {
const { history, route: { match: { path, params: { business_id, tabKey, mode }}}} = this.context.router;
let url = path.replace(':branch_id', val)
.replace(':business_id', business_id)
.replace(':tabKey', tabKey)
.replace(':mode', mode);
history.push(url);
}
路由器实现在哪里?请使用完整的组件codereact路由器dom完成您的问题。