Mic*_*Mic 6 ngrx angular ngrx-store
我想创建一个带有数组作为参数的 Action,但这不会进行类型检查:
export const action_organizations_available = createAction(
CoreActionTypes.ORGANIZATIONS_AVAILABLE,
props<Organization[]>()
);
Run Code Online (Sandbox Code Playgroud)
我明白了props(): "arrays are not allowed in action creators"。当类型不是数组时它工作正常。
使用props<{ organizations: Organization[] }>作品,但我想知道这是否是最佳实践。
期望数组作为操作中的参数时的最佳实践是什么?
tim*_*ver 11
你必须把它包装成一个对象:
export const action_organizations_available = createAction(
CoreActionTypes.ORGANIZATIONS_AVAILABLE,
props<{ organizations: Organization[] }>()
);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1578 次 |
| 最近记录: |