[英]Property 'title' does not exist on type 'never'
In my code, two errors appearing in the title and content in the HTML file.在我的代码中,HTML 文件的标题和内容中出现了两个错误。 I want to input posts item and show them in the list.我想输入帖子项目并将它们显示在列表中。
Property 'title' does not exist on type 'never'. “从不”类型上不存在属性“title”。 Property 'content' does not exist on type 'never'. “从不”类型上不存在属性“内容”。
<ngb-accordion #acc="ngbAccordion" *ngFor="let post of posts">
<ngb-panel id="toggle-1" title="{{post.title}}" >
<ng-template ngbPanelContent>
{{post.content}}
</ng-template>
</ngb-panel>
</ngb-accordion>
this is the ts file这是 ts 文件
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-list',
templateUrl: './list.component.html',
styleUrls: ['./list.component.css']
})
export class ListComponent implements OnInit {
content ="";
etitle = "";
elist = "";
posts = [];
onaddlist() {
const posts = {
title: this.etitle,
content: this.elist
};
}
constructor() { }
ngOnInit(): void {
}
}
There is only one usage of the title
property: post.title
. title
属性只有一种用法: post.title
。 That means that one of the posts
array elements is never
.这意味着posts
数组元素之一是never
。 never
is an indicator of the unreachable block. never
是不可达块的指示符。 I'm sure if you add proper typings for this.posts
, the compiler would indicate an issue.我敢肯定,如果您为this.posts
添加了正确的this.posts
,编译器会指出一个问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.