|
1. actionType 的拆分 纯粹是无聊, 本质意义是搞个 js 文件,把所有的 type 都放进去 ,这步甚至不如swicth 来的方便 -。- 暂且不管他;
2. actionCreator 这玩意呢 ,也是搞个js ,然后 利用传值调用,其实吧 就是把所有action 都集中起来;
2.1 actionCreator.js
- // 这个主要用来统一管理 action
- export const actionChangInpValue = (value)=>({
- type: "chang_inp_value",
- value:value
-
- });
- export const actionChangList = (index)=>({
- type:'chang_list',
- index
- })
复制代码
2.2 TODOlist.js
- import {actionChangInpValue ,actionChangList } from '../store/ActionCreates';
- // 监听input改变
- inpC(e){
- // this.setState({
- // inpValue:e.target.value
- // })
- // console.log(e.target.value)
-
- // 修改之后的数据
- // let action = {
- // type :'chang_inp_value',
- // value:e.target.value
- // }
-
- // 传给数据处理中心中心 利用 dispatch 方法
- store.dispatch( actionChangInpValue(e.target.value) );
-
- }
复制代码
|
|