react-redux基本使用

2023-06-09,,

  1. 图解:
  2. 代码:
    var createStore = require('redux').createStore
    var indexStore = createStore(function(state=0,action){
    switch(action.type){
        case 1:
            return ++state
        case 0:
            return --state
        default:
            return state
    }
    })
    indexStore.subscribe(function(){
    console.log(indexStore.getState())
    })
    indexStore.dispatch({type:1})
  3. 效果:

《react-redux基本使用.doc》

下载本文的Word格式文档,以方便收藏与打印。