📜  react redux 如何在 reducer 中更改对象值 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:36.753000             🧑  作者: Mango

代码示例3
if (action.type == types.FILTER_TITLE_CHANGED) {
    let newState = { ...state };
    newState.filterTitleStr = action.filterTitleStr;
    return newState;
  } else if (action.type == types.FILTER_AUTHOR_CHANGED) {
    let newState = { ...state };
    newState.filterAuthorStr = action.filterAuthorStr;
    return newState;
  } else if (action.type == types.FILTER_CATEGORY_CHANGED) {
    let newState = { ...state };
    newState.filterCategoryStr = action.filterCategoryStr;
    return newState;
  }