这是Table组件{this.props.tableData.map((item,index)=>{return({item.id}{item.name}{item.price}修改)})}这是调用Table组件的父组件constmapDispatch=(dispatch)=>{return{changeTable(){dispatch(reduxTableState())}}}这是store的reducerexportdefault(state=defaultState,action)=>{if(action.type==='changeTable'){console.log(666)returnnewState}我想改变store里table的state的值,需要在store里知道点击的是循环出的哪个,所以需要知道index修改这样是不行的
2 回答
白猪掌柜的
TA贡献1893条经验 获得超10个赞
修改 this.props.handleClick(index)}>修改 constmapDispatch=(dispatch)=>{return{changeTable(index){console.log(index)dispatch(reduxTableState())}}}
holdtom
TA贡献1805条经验 获得超10个赞
接上个答案,exportconstreduxTableState=(index)=>{return{type:constants.TABLE_STORE,index}}到store里就可以在action里取到index了
添加回答
举报
0/150
提交
取消
