1、安装redux yarn add redux2、创建store列表项目创建store文件夹文件夹下创建index.jsindex.js import { createStore } from ‘redux’; const store = createStore(); export default store;3、创建reducer.js const defaultState = { inputValue:"" } export default (state = defaultState,action) => { return state }5、store中如何获取reducer的数据,及改变 //index.js做如下修改 import { createStore } from ‘redux’; import reducer from ‘./reducer’ const store = createStore(reducer); export default store;6、组件中如何获取store数据组件中引入store文件下的index.js在constructor中 this.state = store.getState();7、如何改变store的数据创建action const action = { type:‘input_action’,val:val};store.dispatch(action) -> store ->reducer改变store数据 返回一个新的state数据8、如何监听 store的数据改变,刷新dom组件中的constructor使用 store.subscribe(this.listener.bind(this));listener () { this.setState(store.getState())};