我可以得到一个吗?这就是我所拥有的,但我得到了一条红色的波浪线:
let button = <HTMLElement>document.body.querySelector(".btn");
button.addEventListener("click", () =>{});//not sure what to do here. I know its wrong though.
Run Code Online (Sandbox Code Playgroud)
下面是我的 tsonconfig
{
"compileOnSave": true,
"compilerOptions": {
"noImplicitAny": true,
"removeComments": true,
"sourceMap": false,
"target": "es5",
"lib": [
"es6",
"dom"
]
},
"include": [ "**/*" ]
}
Run Code Online (Sandbox Code Playgroud)
使用您给定的 tsconfig.json,它可以正常编译:
let button = <HTMLElement>document.body.querySelector(".btn");
button.addEventListener("click", () => { });
Run Code Online (Sandbox Code Playgroud)
你的 IDE 在说谎。在 VSCode / alm 中工作正常
| 归档时间: |
|
| 查看次数: |
31546 次 |
| 最近记录: |