跳转传参
- 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