<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>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # Redux教程 ## 1.定義store管理哪些數據 ~~~ import {createStore} from 'redux'; ~~~ ## 2.定義reducer放置數據 ~~~ var defaultState={ inputValue:"hello world", list:[] } export default (state=defaultState,action)=>{ if(action.type==="inputChange"){ var newState = {...state}; newState.inputValue = action.value; return newState; } return state; } ~~~ ## 3.將reducer中的數據和store通信 ~~~ import reducer from './reducer'; const store = createStore(reducer,window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()); export default store; ~~~ ## 4.在app.js中用使用store中的數據 ~~~ import store from './store/index.js'; class App extends Component { constructor(props){ super(props); this.state = store.getState() } } ~~~ ## 5.事件派發action給store ~~~ handleChange=(event)=>{ var action ={ type:"inputChange", value:event.target.value } store.dispatch(action); } ~~~ ## 6.在reducer中改變state ~~~ var defaultState={ inputValue:"hello world", list:[] } export default (state=defaultState,action)=>{ if(action.type==="inputChange"){ var newState = {...state}; newState.inputValue = action.value; return newState; } return state; } ~~~ ## 7.組件訂閱store的改變 ~~~ constructor(props){ super(props); this.state = store.getState() /* 只要store的狀態發生改變的時候就會觸發 */ store.subscribe(this.handleStoreChane) } handleStoreChane=()=>{ this.setState(store.getState()) } } ~~~
                  <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>

                              哎呀哎呀视频在线观看