react-router 不用 Link 怎么跳轉(zhuǎn)路由
1 回答

翻過高山走不出你
TA貢獻1875條經(jīng)驗 獲得超3個贊
history.pushState的話確實只是在history里面添加一條路由記錄,并且改變url,不會刷新頁面,所以內(nèi)容不會變,解決的辦法可以用如下代碼試試:
class Test {
constructor(props, context){
super(props, context);
this.router = context.router;
}
}
Test.contextTypes = {
router: PropTypes.object.isRequired
};
在你ui組件的onChange事件里面寫如下代碼:
this.router.push(...)
- 1 回答
- 0 關(guān)注
- 668 瀏覽
添加回答
舉報
0/150
提交
取消