Error: src/app/ponent.html:7:78 - error TS2339: Property ‘value’ does not exist on type ‘EventTarget’.
7 <input type=“text” [value]=“inputValue” (input)=“inputValue = $event.target.value” >
~~~~~
src/app/ponent.ts:5:16
5 templateUrl: ‘./ponent.html’,
~~~~~~~~~~~~~~~~~~~~~~
Error occurs in the template of component AppComponent.
有没有学Angular或者ts的小伙伴遇到这个问题的???这个是我看视频学的,那个大神就没有出现这样的问题,我哭了。。。。。。
不过我还是尝试解决了一下啊,百度过来的说法基本都是说 这里的event.target是一个HTMLElement,它是所有HTML元素的父元素,但不保证具有属性值。 TypeScript检测到此情况并引发错误。 将event.target强制转换为适当的HTML元素,以确保它是具有值属性的HTMLInputElement
(<HTMLInputElement>event.target).value 说是这样就好了,但是我试了没有用。所以我另辟蹊径,用了这种方法 链接: link.
希望有大神可以解答我的疑惑,冲呀