我有一个复选框TSX(JSX)元素:
<input type="checkbox" name={i.toString()} onClick={this.handleCheckboxClick} />
借助VS代码,我知道的输入参数类型this.handleCheckboxClick
为MouseEvent<HTMLInputElement>
。所以我实现了:
private handleCheckboxClick(event: MouseEvent<HTMLInputElement>) {
...
}
然后我收到一条错误消息[ts] Type 'MouseEvent' is not generic.
,如下图所示:
我的软件包的版本:
"@types/react": "^15.0.29",
"@types/react-dom": "^15.5.0",
"react": "^15.6.1",
"react-dom": "^15.6.1",
"typescript": "^2.3.4",
这是为什么?
type: "checkbox" onChange: (e: MouseEvent<HTMLInputElement>) => void; defaultChec...' is not assignable to type 'InputHTMLAttributes<HTMLInputElement>'