【问题标题】:Angular 13 ElementRef initialization errorAngular 13 ElementRef 初始化错误
【发布时间】:2022-08-23 22:24:23
【问题描述】:

您好我在初始化 viewchild elementRef 时遇到问题 这对我来说总是很好,但是在 angular 13 中我收到一条错误消息


 @ViewChild(\"text\", { static: true }) text : ElementRef;

属性 \'text\' 没有初始值设定项,并且在构造函数中未明确分配

谢谢

    标签: angular


    【解决方案1】:

    改成。

    @ViewChild("text", { static: true }) text!: ElementRef;
    

    阅读更多

    1. Property 'text' has no initializer and is not definitely assigned in the constructor
    2. Not null assertion operator

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-10-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-05
      • 2015-03-18
      • 2019-08-05
      • 2013-04-12
      相关资源
      最近更新 更多