在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML5  HTML/ react-router4.0如何實現(xiàn)兩個子頁面之間參數(shù)傳遞

react-router4.0如何實現(xiàn)兩個子頁面之間參數(shù)傳遞

默認展開的是“應用使能平臺”頁面,radio選擇表格中的某一行,id作為參數(shù),需要傳遞給企業(yè)信息的頁面。在topic這個組件中,無法通過callback的形式進行參數(shù)傳遞,要如何實現(xiàn)兩個子頁面之間數(shù)據(jù)的傳遞???
clipboard.png

clipboard.png

clipboard.png

回答
編輯回答
無標題

笨辦法,單擊radio時,把id放到state中。然后在topic頁面獲取這個state就可以了。

router可以這樣傳呀。

<Link to={`/topic/${selectedId}`}/>
<Router path='/topic/:selectedId' component={/* */} />
2017年7月10日 18:55
編輯回答
扯不斷
//parent
onClick={()=>(this.props.history.push(`/topic`,{selectedId: selectedId}))}
//component
class Index extends Component {
  constructor(props) {
    super(props);
    const { state } = this.props.location;
    let id;
    if (state) {
      if (state.id) {
        id = state.id;
      }
    }
    this.state = {selectedId: id}
    }

不知道這樣能不能滿足你的需求

2017年5月9日 12:16