【发布时间】:2023-01-09 13:10:23
【问题描述】:
创建切片是 接受 reducer 函数对象的函数,其中钥匙在 reducer 对象中将用于生成字符串操作类型常量,如下所示:
const counterSlice = createSlice({
name: 'counter',
initialState: 0,
reducers: {
increment: (state) => state + 1,
},
})
没关系,但我对此感到困惑。 在哪里钥匙和价值观这个对象?
reducers: {
increment(state) {
state.value++
},
decrement(state) {
state.value--
},
incrementByAmount(state, action) {
state.value += action.payload
}
}
【问题讨论】:
标签: javascript redux