700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > error TS2339: Property ‘value‘ does not exist on type ‘EventTarget‘. 7 <input type=“text“ [value]=

error TS2339: Property ‘value‘ does not exist on type ‘EventTarget‘. 7 <input type=“text“ [value]=

时间:2023-07-09 15:48:06

相关推荐

error TS2339: Property ‘value‘ does not exist on type ‘EventTarget‘.  7 <input type=“text“ [value]=

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.

希望有大神可以解答我的疑惑,冲呀

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。