nmt*_*nmt 8 typescript angular
出现以下错误:
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] ="i"
[title]="entry.title" [date]="entry.date"
[body]="entry.body"></app-journal-entry>
</div>
Run Code Online (Sandbox Code Playgroud)
Sem*_*ore 15
启用 strictTemplates 时会发生错误,我认为这是一个错误。
您可以使用“$any(*)”
所以不要使用 [title]="entry.title"
你应该使用 [title]=$any(entry.title)
有关更多信息,请参阅链接 https://github.com/angular-split/angular-split/issues/220
归档时间: |
|
查看次数: |
7723 次 |
最近记录: |