相关疑难解决方法(0)

Ngrx:无法分配给对象“[Object]”的只读属性“Property”

我正在使用 ngrx 商店。

在我的状态下,我必须物品

export interface ISchedulesState {
  schedulings: ISchedules;
  actualTrips: ISchedule[];
}
Run Code Online (Sandbox Code Playgroud)

这是我的接口

export interface ISchedules {
  [key: string]: ISchedule[];
}

export interface ISchedule {
  dest: number;
  data: string
}
Run Code Online (Sandbox Code Playgroud)

在减速器中我更新 actualTrips

export const SchedulingReducers = (
  state = initialSchedulingState,
  action: SchedulesAction
): ISchedulesState => {
  switch (action.type) {
    case ESchedulesActions.GetSchedulesByDate: {
      return {
        ...state
      };
    }
    case ESchedulesActions.GetSchedulesByDateSuccess: {
      return {
        ...state,
        schedulings: action.payload
      };
    }
    case ESchedulesActions.GetSchedulesByTime: {
      let time = action.payload;
      state.actualTrips = [...(state.schedulings[time] || [])]; …
Run Code Online (Sandbox Code Playgroud)

javascript javascript-objects typescript ngrx angular

14
推荐指数
3
解决办法
2万
查看次数