[英]Error with reactive forms Angular, Property 'X' has no initializer and is not definitely assigned in the constructor
[英]How can I solve typescript error 'x' has no initializer and is not definitely assigned in the constructor?
我收到错误
Property 'duni' has no initializer and is not definitely assigned in the constructor.ts(2564)
在下面的行
@ViewChild('bhondu') duni: ElementRef<HTMLTableDataCellElement>;
使用?
在我使用this.duni.nativeElement
的其他地方中断代码,给出Object is possibly 'undefined'.ts(2532)
。 如何在不更改配置文件中的任何属性的情况下解决此错误?
使用非空断言运算符
@ViewChild('bhondu') duni!: ElementRef<HTMLTableDataCellElement>;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.