<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國際加速解決方案。 廣告
                [toc] ### 引入store ``` import {createStore, applyMiddleware} from 'redux' import reducer from './reducer' import thunk from 'redux-thunk' // 引入后 action 可以 return 一個方法,否則只能是對象 import { createLogger } from 'redux-logger' // 查看 store const store = createStore( reducer, applyMiddleware(thunk, createLogger()), ); // 創建數據倉庫 store.getState() // 獲取 state 值 store.dispatch(action) // 直接dispatch action export default store; ``` ### action action的兩種寫法,引入中間件 thunk前,返回一個對象, store.dispatch(action) ``` export const getInputChangeAction = (value) => ({ type: CHANGE_INPUT_VALUE, value }) const action = getInputChangeAction(e.target.value) store.dispatch(action) ``` 引入 thunk 后,可以返回一個方法,thunk相當于給 dispatch 做了升級 ``` const action = getTodoList() store.dispatch(action) // 直接執行,action 中的方法,其中方法中默認有一個dispatch,用來傳遞給 action export const getTodoList = () => { return (dispatch) => { axios.get('http://127.0.0.1:3001/test').then(res => { const action = initListAction(res.data) dispatch(action) }) } } export const initListAction = (data) => ({ type: INIT_LIST_ACTION, data }) ``` ### reducer ``` if (action.type === ADD_TODO_ITEM) { const newState = JSON.parse(JSON.stringify(state)) newState.list.push(newState.inputValue) newState.inputValue = ''; return newState } ```
                  <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>

                              哎呀哎呀视频在线观看