react 编程式路由
路由跳转
// 车型分类详情 carClassBtn =(id)=> { this.props.history.push('/forumDetail')//路由地址 }
路由跳转带参数
// 车型分类详情 carClassBtn =(id)=> { this.props.history.push({ pathname:'/forumDetail',// 跳转地址 state:{// 传参对象 id, name: '车型分类' }, }) }
获取路由传过来的参数
// 进入页面就获取路由参数 componentDidMount() { console.log(this.props.history.location.state); } // 监听路由参数变化 componentWillReceiveProps(nextProps) { console.log(nextProps.history.location.state,'nextProps'); }

浙公网安备 33010602011771号