我正在使用TypeScript和Angular 6,我正在尝试利用我的鼠标事件。
但是,根据此代码:
if (event.clientX < 260){
return [x + 20, ny - 190]
}
else {
return [x - 240, ny - 190]
}
我收到一条错误说明
“'事件'类型中不存在'属性'clientX'。
代码仍然按预期运行。
我怎么能解决这个问题,所以我似乎没有错误?谢谢!
您可以如下所示声明传递事件的参数类型,
someFunc(event: MouseEvent): void {
if (event.clientX< 260){
return [x+20, ny - 190]
}
else {
return [x-240, ny - 190]
}
}