javascript 方法表达式不是函数类型
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26540554/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Method expression is not of Function type
提问by elixenide
I have the following JavaScript file:
我有以下 JavaScript 文件:
/*global $ */
function foo() {
'use strict';
var $tr = $('table tr'),
$td = $tr.children('td');
$td.html('Hello World');
}
In PHPStorm, children
gets underlined with a weak warning. Mousing over it reveals this message:
在 PHPStorm 中,children
带有弱警告下划线。将鼠标悬停在它上面会显示以下消息:
Method expression is not of Function type
方法表达式不是函数类型
This file is in the same directory as jquery.min.js (v. 1.11.0, if that matters).
此文件与 jquery.min.js 位于同一目录中(v. 1.11.0,如果这很重要)。
How can I fix this?
我怎样才能解决这个问题?
Note that the above example is a minimalist example sufficient to reproduce the problem; it's not my actual code, but it will product the same result.
请注意,上面的示例是一个足以重现问题的极简示例;这不是我的实际代码,但它会产生相同的结果。
采纳答案by elixenide
I have my answer thanks to Arun P Johny. I needed to have jquery-1.11.1.js (the uncompressed version) somewhere in my project. I added it, and PHPStorm immediately resolved all jQuery-related warnings.
感谢 Arun P Johny,我得到了答案。我需要在我的项目中的某个地方使用 jquery-1.11.1.js(未压缩版本)。我添加了它,PHPStorm 立即解决了所有与 jQuery 相关的警告。
回答by JochenJung
Another solution would be to add jQuery as a library here:
另一个解决方案是在此处添加 jQuery 作为库:
Settings/Preferences dialog, click JavaScript under Languages and Frameworks, then click Libraries.
设置/首选项对话框,单击语言和框架下的 JavaScript,然后单击库。