出现以下错误:
Error: src/app/pages/journal-list/journal-list.component.html:27:23 - error TS2322: Type 'string' is not assignable to type 'number'.
27 [title]="entry.title" [date]="entry.date"
~~~~~~~~~~~~~~~~~~~
src/app/pages/journal-list/journal-list.component.ts:7:16
7 templateUrl: './journal-list.component.html',
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Error occurs in the template of component JournalListComponent.
src/app/pages/journal-list/journal-list.component.html:26:1 - error TS2322: Type 'number' is not assignable to type 'string | any[] | null | undefined'.
26 [routerLink] ="i"
~~~~~~~~~~~~~~~~~
src/app/pages/journal-list/journal-list.component.ts:7:16
7 templateUrl: './journal-list.component.html',
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Error occurs in the template of component JournalListComponent.
Run Code Online (Sandbox Code Playgroud)
显然是因为我正在使用属性绑定 [date]="entry.date"。我已将财产日期声明为数字。为什么会出现这种情况?
上下文的代码片段:
<div class="entries-list">
<app-journal-entry *ngFor="let entry of entries; index as i"
[routerLink] …Run Code Online (Sandbox Code Playgroud)