<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                [toc] ## old ### 使用 父容器 ``` export default class xxx extends React.Component{ static childContextTypes = { location:PropTypes.object ,history:PropTypes.object } getChildContext(){ let that = this; return { location:this.state.location ,history:{ push(path){ if(typeof path == 'object'){ // state 是用來保存狀態的 let {pathname,state} = path; that.setState({location:{...that.state.location,state}},()=>{ window.location.hash = pathname; }) }else{ window.location.hash = path; //會自動添加'#' } } } } } ``` 子孫 ``` static contextTypes = { location: PropTypes.object , history: PropTypes.object } ... this.context -> 指向的即是 contextTypes聲明的對象 ... ``` ### 注意事項 ``` getChildContext(){ return { location:this.state.location ,history:(hash)=>{ window.location.hash = hash; } } } <<< index.js:2178 Warning: Failed child context type: Invalid child context `history` of type `function` supplied to `xxx`, expected `object`. in xxx (at App.js:11) ``` return的必須是一個對象,且這個對象里的屬性的值也必須是對象,否則就會像上栗一樣報錯 ``` getChildContext(){ return { location:this.state.location ,history:{ push:(hash)=>window.location.hash = hash } } } ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看