Property 'value' does not exist on type 'EventTarget'

前端 未结 7 2077
深忆病人
深忆病人 2020-11-30 00:40

I am using TypeScript Version 2 for an Angular 2 component code.

I am getting error "Property \'value\' does not exist on type \'EventTarget\'" for below co

7条回答
  •  [愿得一人]
    2020-11-30 01:24

    Here is the simple approach I used:

    const element = event.currentTarget as HTMLInputElement
    const value = element.value
    

    The error shown by TypeScript compiler is gone and the code works.

提交回复
热议问题