久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      react跳轉(zhuǎn)傳值怎么實現(xiàn)

      react跳轉(zhuǎn)傳值的實現(xiàn)方法:1、通過“history.push”或“NavLink”實現(xiàn)頁面跳轉(zhuǎn);2、通過“this.props.history.push({pathname: 'login',query: {id: …,name: …}})this.props.history.push('modify')”實現(xiàn)傳值即可。

      react跳轉(zhuǎn)傳值怎么實現(xiàn)

      本教程操作環(huán)境:Windows10系統(tǒng)、react18.0.0版、Dell G3電腦。

      react跳轉(zhuǎn)傳值怎么實現(xiàn)?

      react項目頁面跳轉(zhuǎn)/傳值

      一、跳轉(zhuǎn)

      1、history.push 跳轉(zhuǎn)

      • 引用 withRouter
      • 導(dǎo)出組件時使用

      import { withRouter } from 'react-router-dom';  class Header extends React.Component {  } export default withRouter(Header);
      登錄后復(fù)制

      2、NavLink跳轉(zhuǎn)

      import { NavLink } from "react-router-dom"; <NavLink to="/modify">修改密碼</NavLink>
      登錄后復(fù)制

      二、傳值

      1、路由傳值 query/params

      this.props.history.push({     pathname: 'login',     query: {         id: 3231,         name: 3231     }})this.props.history.push('modify')
      登錄后復(fù)制

      2、路由傳值獲取參數(shù)

      this.props.match.query.id // 3231 this.props.match.params.name // 3231
      登錄后復(fù)制

      react跳轉(zhuǎn)傳值怎么實現(xiàn)

      3、props傳值

      父組件:

      state = {     collapsed: false,};render() {     const { collapsed } = this.state;     return (         <Slider collapsed={collapsed}/>     )}
      登錄后復(fù)制

      子組件:

      componentDidMount(){     // console.log(this.props)     const { pathname } = this.props.location    if( pathname ) {         this.setState({                            selectedKeys:this.props.location.pathname        })     }}
      登錄后復(fù)制

      console.log(this.props)
      react跳轉(zhuǎn)傳值怎么實現(xiàn)

      推薦學(xué)習(xí):《react視頻教程》

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號