1.使用router傳參。this
傳值:url
在router跳轉組件的時候在跳轉的路徑後邊添加須要傳遞的值: this.props.history.push('url'+id) //id是咱們要傳的值。 而後在註冊router的時候在路徑後面用冒號隔開添加參數。 <Route path="/url/:corpId" component={url} />
接收:code
在跳轉結束的頁面經過this.props接收: this.props.match.params.id;
2. 經過this.props傳遞component
咱們封裝組件,組件裏的事件 經過調用組件的時候。直接經過this.props.參數就能夠從父級得到參數值。
3.封裝global組件router
在index.js裏引用就能夠全局調用了。