这是我的代码可以帮助它如何正确编写切片功能 export default function(state={inputs:[ ]}, action) { console.log(action.index); switch (action.type) { case APPEND_INPUT: return { ...state, inputs: state.inputs.concat({value
export default function(state={inputs:[ ]}, action) { console.log(action.index); switch (action.type) { case APPEND_INPUT: return { ...state, inputs: state.inputs.concat({value:"",key:"1",type:'input'})}; case APPEND_TEXTAREA: return { ...state, inputs: state.inputs.concat({value:"",key:"",type:'textarea'})}; case APPEND_EMAIL: return { ...state, inputs: state.inputs.concat({value:"",key:"",type:'email'})}; case REMOVE_INPUT: return {inputs: state.inputs.slice(0)}; default: return state; } }要么:
{inputs: state.inputs.filter((_, i) => i !== action.index))