我得到一个错误的时候,构建Angular 应用程序.
HTML Template个
<mat-form-field *ngIf="requested">
<input
matInput
(input)="sendingAccesscode($event)"
placeholder="{{ 'CODE_LABEL' | i18next }}"
name="accesscode"
formControlName="accesscode"
minlength="6"
required
/>
</mat-form-field>
TypeScript个
sendingAccesscode(event: { target: { value: string }}) {
if (event.target?.value.length >= 6) {
this.accessCode.emit(event.target.value);
}
}
我收到以下错误:
error TS2345:
Argument of type 'Event' is not assignable to parameter of type '{ target: { value: string; }; }'.
Types of property 'target' are incompatible.
Type 'EventTarget | null' is not assignable to type '{ value: string; }'.
Type 'null' is not assignable to type '{ value: string; }'.
13 (input)="sendingAccesscode($event)"
~~~~~~```