typescript 打字稿中的 HTMLElement.addEventListener 示例?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42796613/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 07:37:23 来源:igfitidea点击:
example of HTMLElement.addEventListener in typescript?
提问by Mike_G
can I get one? this is what I have, but I'm getting a red squiggly line:
我可以得到一个吗?这就是我所拥有的,但我得到了一条红色的波浪线:
let button = <HTMLElement>document.body.querySelector(".btn");
button.addEventListener("click", () =>{});//not sure what to do here. I know its wrong though.
below is my tsonconfig
下面是我的 tsonconfig
{
"compileOnSave": true,
"compilerOptions": {
"noImplicitAny": true,
"removeComments": true,
"sourceMap": false,
"target": "es5",
"lib": [
"es6",
"dom"
]
},
"include": [ "**/*" ]
}