【发布时间】:2018-06-01 18:56:32
【问题描述】:
我使用 PhpStorm,当我使用 JSDoc 将参数定义为 jQuery 类型时,它会给我警告。
我尝试将 jQuery 配置为一个库,但它似乎不起作用。
这是我的代码:
/**
* @param {jQuery} $button
*/
function setActive($button)
{
// The code is working fine, but PhpStorm is giving the warning
// "Unresolved function or method addClass()" here.
$button.addClass("active");
// If I try to do this, no warning is displayed.
$("#test").addClass("test");
}
编辑:
一些方法出现在智能感知中(我不知道为什么),但不幸的是addClass 不是其中之一。
【问题讨论】:
-
这很奇怪。它对我来说将参数识别为 jQuery。
-
@Phiter 你的 PHPStorm 有什么特殊配置吗?这似乎是正确的,但我就是无法摆脱这个警告。
-
没什么特别的。如果你使用
$('body').,它会用jQuery函数自动完成吗? -
是的,它适用于 $() 中的任何内容。它不仅适用于参数。
标签: jquery phpstorm webstorm jsdoc