![](/img/trans.png)
[英]JavaScript runtime error: Object doesn't support property or method 'jqGrid'
[英]JSHint error “Object doesn't support this property or method” for javascript closures
我有這個javascript:
(function ($) {
// a comment
})(window.jQuery);
命令:
%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)
( $(ItemPath)
替換為Visual Studio中的當前選定項)
...這給了我這個輸出:
[%pathname%\js\JScript1.js]
Line 3 character 18: Object doesn't support this property or method
Implied globals:
window: 3
我嘗試過安排使用JSLint樣式的括號,但這給了我同樣的錯誤:
(function ($) {
// a comment
}(window.jQuery));
我的JavaScript代碼有問題嗎?或者這是JSHint錯誤?
更新:我傾向於JSHint錯誤,此javascript:
(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:我認為這是將args傳遞給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:事實證明,我確實是個白痴。
我正在嘗試使用最新的: https : //nodeload.github.com/jshint/jshint/zipball/master
...當我應該一直使用r09時 : https : //nodeload.github.com/jshint/jshint/zipball/r09
因此,這是最新的master版本中的錯誤,並且已在r10版本中修復: http : //www.jshint.com/changelog/
您不希望通過自我實例化的匿名函數將window.jQuery
作為參數傳遞,而是通過window, jQuery
傳遞。 對象window
沒有方法jQuery
,因此出現錯誤。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.