【发布时间】:2022-06-17 20:23:50
【问题描述】:
我使用ngrx并尝试提交我的formData,这是我的代码:
formData = new FormData();
onSubmit() {
this.formData.set(\'name\', this.userForm.get(\'name\')?.value);
this.formData.set(\'description\', this.userForm.get(\'description\')?.value);
this.formData.set(\'price\', this.userForm.get(\'price\')?.value);
this.formData.set(\'category\', this.userForm.get(\'category\')?.value);
this.formData.set(\'available\', this.userForm.get(\'available\')?.value);
this.store.dispatch(AddItem({this.formData} ))
}
当我尝试调度 addItem 操作时出现错误:Argument of type \'{ this: any; }\' is not assignable to parameter of type \'{ item: Item; }\'.
addItem 操作代码是这样的:
export const AddItem = createAction(
ItemActionsNames.AddItems,
props<{ item: Item }>()
);
那么我该如何解决这个错误???
-
如果我的回答对您的问题有所帮助,我们非常欢迎您接受它作为解决方案,这样有类似问题的其他人可以更轻松地找到它。周末愉快