jQuery支持在html中起作用,但在.js中不起作用? [英] jquery support works in html but not in .js?

查看:250
本文介绍了jQuery支持在html中起作用,但在.js中不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试使用komodo来构建jquery ui小部件..我启用了jquery api参考,并在.html文件中运行良好..然后打开我的widget.js文件并输入;

Trying out komodo to build a jquery ui widget.. I enabled the jquery api reference and in a .html file it works great.. I then open my widget.js file and type in;

(function($) {

之后

$.

我希望在这里得到智能,但我得到:

I would expect to get intellisense here, but instead I get:

未找到完成项. (确定完成情况时出错)

No completions found. (Error determining completions)

这是文件扩展名吗?只是不支持jQuery ui小部件吗?

Is this a file extension thing? Are jquery ui widgets just unsupported?

推荐答案

来自科莫多的人;

问题是科莫多不知道匿名用户的上下文 函数调用-换句话说,Komodo不够聪明,无法知道 在这种情况下,"jQuery" =="$".

The problem is that Komodo doesn't know the context of the anonymous function call - in other words Komodo is not smart enough to know that "jQuery" == "$" in this case.

但是一切并没有丢失,您可以通过告诉Komodo哪些内容可以帮助他们. 在这种情况下就是类型.这是使用jsDoc帮助的示例 定义"$"的类型:

But all is not lost, you can help out Komodo by telling it what the type is in such cases. Here is the example that uses jsDoc to help define the type of "$":

   (/** @param {jQuery} $ */function($) {
       $. // will show jQuery completions now
   })(jQuery)

;

这篇关于jQuery支持在html中起作用,但在.js中不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆