【发布时间】:2019-05-05 07:16:25
【问题描述】:
在我的项目中,我有一些代码可以检查支持哪个鼠标滚轮(针对不同的浏览器),因此我们可以正确添加事件侦听器。这是它的外观:
const support = 'onwheel' in document.createElement('div')
? 'wheel'
: document.onmousewheel !== undefined
? 'mousewheel'
:'DOMMouseScroll';
它有效。不过,我最近改用Visual Studio Code,现在出现了一个常量问题:
“文档”类型上不存在属性“onmousewheel”。
这是一个有效且有用的错误。但是,在这种情况下,我想忽略它,因为这是我正在检查的内容。
有什么方法可以让我只在这一行忽略这个问题?当我使用 TypeScript 时,我尝试过 // tslint:disable-line,但我认为这是 VS Code 本身。任何帮助表示赞赏。
【问题讨论】:
-
document['onmousewheel'], (document as any).onmousewheel
标签: typescript visual-studio-code eslint lint tslint