简体   繁体   English

为什么jslint无法识别“窗口”

[英]Why doesn't jslint recognize “window”

even when I select in the browser . 即使in the browser选择。 I thought every browser used this as the global object. 我以为每个浏览器都将此作为全局对象。

I have to type it in manually in the globals section to make it go away. 我必须在globals部分中手动键入它才能消失。

It's part of the JSLint specification. 它是JSLint规范的一部分。 The exact reason I'm not sure (you'd have to ask the jslint devs). 我不确定的确切原因(您必须询问jslint开发人员)。 If you use the "assume a browser" option it will add common globals for you but window isn't one of them : 如果您使用“假定浏览器”选项,它将为您添加通用全局变量,但window 不是其中之一

browser

true if the standard browser globals should be predefined. 如果应该预定义标准浏览器全局变量,则为true This option will reject the use of import and export. 此选项将拒绝使用导入和导出。 This option also disallows the file form of the 'use strict' pragma. 此选项还不允许“使用严格”杂注的文件格式。 It does not supply self or window ; 它不提供selfwindow you will have to request these aliases of the dreaded global object yourself. 您将必须自行请求这些可怕的全局对象的别名。

(my emphasis) (我的重点)

You'll have to add 您必须添加

/*global
window, self
*/

...to tell JSLint about them. ...告诉JSLint他们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM