[英]JSLint Unexpected 'this' Error
为什么我从下面的代码中收到以下JSLint错误:
JSLint:意外的“ this”。
var environment = {
development: "Development",
staging: "Staging",
production: "Production",
current: function () {
return process.env.ASPNET_ENV || this.development;
},
isDevelopment: function () {
return this.current() === this.development;
},
isStaging: function () {
return this.current() === this.staging;
},
isProduction: function () {
return this.current() === this.production;
}
};
我已经见过了几个类似的问题这一个,但上面的代码,其中“这个”以不同的方式使用无成交。
这很奇怪,但是似乎JSLint默认情况下不允许“ this”。
但是,他们的文档中有一个“ Tolerate this”选项。 因此,我想向您的jslint配置添加一个选项,如下所示:
/*jslint this:true */
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.