我正在使用 AngularJS (v1.5) 编写一个网络应用程序,所以我有一些 Controller ,在这些 Controller 中我经常声明如下内容:
function myController($someDirectives, ...){
var ctrl = this;
// My code
}
问题是当我对我的代码进行 JSHint 时,我收到了针对我在 Controller 中声明的所有“this”的警告消息:
If a strict mode function is executed using function invocation, its 'this' value will be undefined.
我必须明确指出,在我的 .jshintrc 文件中,我设置了 "strict":false
。
有谁知道如何特别禁用此消息?
提前致谢。
最佳答案
在.jshintrc
文件中设置配置
{
"validthis": true // Tolerate using this in a non-constructor
}
关于javascript - 如何使用 JSHint 禁用有关 'this' 和严格模式的警告?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42349051/