我想问你是不是伊默?
addProduct: (state, action: PayloadAction<Omit<IProductsListDataOnPress, 'onPress' | 'onLongPress'>>) => { state.shopcart = [...state.shopcart, action.payload] }, removeProduct: (state, action: PayloadAction<{ id: string; }>) => { state.shopcart = state.shopcart.filter(el => el.id !== action.payload.id); },
我忘了什么时候使用immer了吗?
应该可以完全正常工作。
第一个也可能是
addProduct: (state, action: PayloadAction<Omit<IProductsListDataOnPress, 'onPress' | 'onLongPress'>>) => { state.shopcart.push(action.payload) },