Ras*_*sta 16 javascript typescript angular
当我使用
@ViewChild('serachField', { static: false }) serachField: ElementRef<HTMLInputElement>
我收到错误
Property 'serachField' has no initializer and is not definitely assigned in the constructor.
Run Code Online (Sandbox Code Playgroud)
我通常初始化变量,但我不确定在这种情况下该怎么做
我试过了
@ViewChild('serachField', { static: false }) serachField: ElementRef<HTMLInputElement> = new ElementRef<HTMLInputElement>(--unsure what the parameter should be--)
Run Code Online (Sandbox Code Playgroud)
我得到:
Expected 1 arguments, but got 0.ts(2554)
core.d.ts(2253, 17): An argument for 'nativeElement' was not provided.
Run Code Online (Sandbox Code Playgroud)
Ras*_*sta 35
谢谢@Isbn
我用了:
@ViewChild('serachField', { static: false }) serachField: ElementRef<HTMLInputElement> = {} as ElementRef;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11015 次 |
| 最近记录: |