我使用 NgRx。
调度动作是:
this.store.dispatch(RegistryActions.ToggleRegistryBlockAction(block));
其中块有类型:
export interface RegistryGroup extends RegistryGeneric {
open: boolean;
}
行动:
export const ToggleRegistryBlockAction = createAction(
"[ToggleRegistryBlockOpen] - Toggle Registry",
props<{ block: RegistryGroup }>()
);
为什么我会在线上收到此错误this.store.dispatch(RegistryActions.ToggleRegistryBlockAction(block));
:
Argument of type 'RegistryGroup' is not assignable to parameter of type '{ block: RegistryGroup; }'.
Property 'block' is missing in type 'RegistryGroup' but required in type '{ block: RegistryGroup; }'.ts(2345)
registry.actions.ts(47, 11): 'block' is declared here.
通过定义这样的动作参数,props<{ block: RegistryGroup }>()
您希望您将传递{block: someGroup}
对象,而不仅仅是someGroup
. 修复它只需将它包装在对象括号中
this.store.dispatch(RegistryActions.ToggleRegistryBlockAction({block}));
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句