跳轉傳參
- Link跳轉
<Router history={history}>
<Route path="messages/:query" component={Message} />
</Router>
============================================
<Link to={{pathname: `/messages/{param}` activeClassName="active">
<img src={rowData.goodsImages} style={styles.goodImage}/>
</Link>
參數獲取 this.props.params.query
<Router history={history}>
<Route path="GoodsDetail" component={GoodsDetail} />
</Router>
============================================
<Link to={{pathname: "/GoodsDetail", query:{goodsId: rowData.goodsId} }} activeClassName="active">
<img src={rowData.goodsImages} style={styles.goodImage}/>
</Link>
參數獲取 this.props.location.query
- history跳轉
browserHistory絕對路徑
hasHistory相對路徑
<Router history={history}>
<Route path="UserOrderLogistics" component={User_OrderLogistics} />
</Router>
============================================
gotoHomeView() {
this.props.homePressDown();
hashHistory.push({
pathname:'/UserOrderLogistics',
query:{ship_no:ship_no,ship_id:ship_id}
});
}
參數獲取 this.props.location.query
- IndexLink
<Router history={history}>
<Route path="/" component={App}/>
</Router>
============================================
如果鏈接到根路由/,不要使用Link組件,而要使用IndexLink組件
<IndexLink to="/" activeClassName="active">
Home
</IndexLink>
或者使用hasHistory
最后編輯于 :
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。