赞
踩
this.props.history.push(`/Page2/Div1`)
//等同于
<Link to=`/Page2/Div1`></Link>
this.props.history.push(`/Page2/Div1`,{ id: 1, message: "你好啊" })
//等同于
<Link to={{pathname:`/Page2/Div1`,state:{id: 1, message: "你好啊"}}></Link>
this.props.history.replace(`/Page2/Div1`)
//等同于
<Link replace to=`/Page2/Div1`></Link>
this.props.history.replace(`/Page2/Div1`,{ id: 1, message: "你好啊" })
//等同于
<Link replace to={{pathname:`/Page2/Div1`,state:{id: 1, message: "你好啊"}}></Link>
代码:
import React, { Component } from 'react'
import { withRouter } from 'react-router'
class div3 extends Component {
render() {
return (
<div>
一个普通组件
</div>
)
}
}
export default withRouter(div3);
经过withRoute处理后的这个普通组件,就可以拥有路由组件的props了
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。