Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
JSHint错误“;对象没有';“不支持此属性或方法”;对于javascript闭包_Javascript_Jslint_Wsh_Jshint - Fatal编程技术网

JSHint错误“;对象没有';“不支持此属性或方法”;对于javascript闭包

JSHint错误“;对象没有';“不支持此属性或方法”;对于javascript闭包,javascript,jslint,wsh,jshint,Javascript,Jslint,Wsh,Jshint,我有一个javascript: (function ($) { // a comment })(window.jQuery); (function ($) { // a comment })(window.jQuery); // is this a bug? window.alert("maybe?"); 我正在使用以下选项运行的: 命令: %systemroot%\system32\cscript.exe 论据: //Nologo "%userprofile%\Docum

我有一个javascript:

(function ($) {
    // a comment
})(window.jQuery);
(function ($) {
    // a comment
})(window.jQuery);
// is this a bug?
window.alert("maybe?");
我正在使用以下选项运行的:

命令:

%systemroot%\system32\cscript.exe
论据:

//Nologo "%userprofile%\Documents\jshint\env\wsh.js" /forin:true,noarg:true,noempty:true,eqeqeq:true,bitwise:true,undef:true,unused:true,browser:true,jquery:true,indent:4,maxerr:500 $(ItemPath)
(Visual Studio中的
$(ItemPath)
被当前选定的项目替换)

…它给了我这个输出:

[%pathname%\js\JScript1.js]
Line 3 character 18: Object doesn't support this property or method

Implied globals:
    window: 3
我试着安排帕伦夫妇使用风格,但这给了我同样的错误:

(function ($) {
    // a comment
}(window.jQuery));
我的javascript是否有问题,或者这是一个JSHint错误

更新:我倾向于JSHint bug,这个javascript:

(function ($) {
    // a comment
})(window.jQuery);
(function ($) {
    // a comment
})(window.jQuery);
// is this a bug?
window.alert("maybe?");
给我这个错误:

Line 5 character 23: Object doesn't support this property or method
更新#2:我认为这是将参数传递到
wsh.js的正确方法:

//U //Nologo "%userprofile%\Documents\jshint\env\wsh.js" /forin:true /noarg:true /noempty:true /eqeqeq:true /bitwise:true /undef:true /unused:true /browser:true /jquery:true /indent:4 /maxerr:500 $(ItemPath)
但是,该代码:

(function (w, $) {})(window, jQuery);
仍然输出以下内容:

[%pathname%\js\JScript1.js]
Line 1 character 37: Object doesn't support this property or method
更新#3:事实证明,我确实是个白痴

我试图使用最新的:

…当我应该使用r09时:

您不希望通过自实例化匿名函数将
window.jQuery
作为参数传递,而是希望通过
window、jQuery
传递。对象
窗口
没有方法
jQuery
,因此出现了错误。

因此这是最新master中的一个错误,r10版本已经修复:

您确定错误不在wsh.js中吗?在wsh.js的第3行char 18有什么可疑的地方吗?@Dan Davies Brackett可能是,但是在我的源代码js.JSHint维护程序中,这一行和字符总是变为最后一个字符。你能创建一张票吗?师父不应该这样失败。谢谢好的,提交:我不确定是这样的,我在调用wsh.js时将
browser:true,jquery:true
作为参数传递。此外,此代码还有相同的错误:
(函数($){})(“hi”)
Plus,当使用
window.jQuery
时,
.jQuery
将只是
window
对象的
未定义的属性。