Eclipse 中的 Javascript 资源有什么好处?
当我在 Eclipse 中创建动态 Web 项目时,它会生成 Javascript 资源 元文件夹;在我第一次尝试使用它之前我认为它有效 就像 Java 资源 - 如果您在此处添加源代码,IDE 将为您提供 智能感知、文档和错误检查。
但是当我尝试在那里添加 jquery.js 时,我没有发现任何我期望看到的东西。 是的,eclipse 告诉我它现在知道 jQuery 对象,但它什么也不知道 关于 jQuery 的方法(如 jQuery.ajax(...)
),它也无法识别 $
快捷方式。
如何让 Eclipse 识别我包含的 js 库的方法?
When I make Dynamic Web Project in Eclipse it generates Javascript Resources
meta-folder; before I tried to use it at first time I thought that it works
just like Java Resources - if you add your source here IDE provides you with
Intellisense, documentation and error checking.
But when I tried to add jquery.js there, I found nothing that I was expecting to see.
Yes, eclipse shows me that it's aware of jQuery object now but it knows nothing
about jQuery's methods (like jQuery.ajax(...)
) and it also doesn't recognize $
shortcut.
How can I make eclipse recognize methods of js libraries that I include?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这两件事并不像你想象的那样相关。 JavaScript 资源节点指示所有已知的全局变量和命名的“类型”及其属性,根据您设置项目的 JavaScript 包含路径的方式进行组织。它代表了项目中 JavaScript(独立和客户端)已知的所有内容——这就是 Content Assist 能够为您提供的内容,我们希望以布局良好且可浏览的结构显示。
您遇到的情况是,jQuery 比 JSDT 理解的更加动态,并且在语法上可能有点棘手。谷歌搜索 jQuery 和 JSDT 应该可以帮助您找到一个在这方面有帮助的插件。
The two things aren't related in the way you think. The JavaScript Resources node indicates all of the known globals and named "types", as well as their properties, organized according to the way you've set up the project's JavaScript Include Path. It represents everything that is known to the JavaScript (standalone and client-side) in your project--this is what Content Assist will be able to offer you, shown in what we hope is a nicely laid out and browseable structure.
What you've run into is that jQuery is more dynamic, and perhaps a little trickier syntactically, than JSDT understands. Googling for both jQuery and JSDT should help you find a plug-in that helps in that regard.