守候你守候我
2019-07-09 12:33:59
如何在Reaction-路由器V4中傳遞與歷史相同的參數。推送/鏈接/重定向?如何傳遞參數this.props.history.push('/page')反應-路由器v4?.then(response => {
var r = this;
if (response.status >= 200 && response.status < 300) {
r.props.history.push('/template');
});
3 回答

九州編程
TA貢獻1785條經驗 獲得超4個贊
var r = this;
if statement
根據醫生的說法:
歷史對象通常具有以下屬性和方法:
長度-(數字)歷史堆棧中的條目數 操作-(字符串)當前操作(推送、替換或彈出)
位置-(對象)當前位置??赡芫哂邢铝袑傩裕?/trans>
路徑名-(字符串)URL的路徑 搜索-(字符串)URL查詢字符串 散列-(字符串)URL散列片段 狀態-(字符串)位置特定的狀態,當這個位置被推送到堆棧上時,它被提供給例如Push(path,state)。僅在瀏覽器和內存歷史記錄中可用。 推動(路徑,[狀態])-(函數)將一個新條目推到歷史堆棧上 替換(path,[state])-(函數)替換歷史堆棧上的當前條目 Go(N)-(函數)通過n個條目移動歷史堆棧中的指針 GoBack()-(函數)等價于go(-1) GoForward()-(函數)等價于go(1) 塊(提示)-(函數)阻止導航
this.props.history.push({ pathname: '/template', search: '?query=abc', state: { detail: response.data }})
Link
Redirect
<Link to={{ pathname: '/template', search: '?query=abc', state: { detail: response.data } }}> My Link </Link>
/template
this.props.location.state.detail
withRouter
.
根據文件:
帶路由器
您可以訪問歷史對象的屬性和最近的 <Route>'s
匹配通過 withRouter
高階部件。 withRouter
每次路由發生變化時,都會重新呈現其組件。 <Route>
渲染 props: { match, location, history }
.
添加回答
舉報
0/150
提交
取消