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

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