Webstorm 外部库说明 [英] Webstorm external libraries explanation
问题描述
我阅读了解释 Webstorm 中的外部库是什么的这个页面,但我还有更多问题:https://www.jetbrains.com/webstorm/help/configuring-javascript-libraries.html
I read this page that explains what external libraries in Webstorm are, but I still have more questions: https://www.jetbrains.com/webstorm/help/configuring-javascript-libraries.html
外部库是否仅用于代码完成和生产帮助?它们可以用于链接库,例如在 index.html 中吗?(可能没有,因为在项目文件夹中找不到它们).
Are external libraries only for code completion and help in production? Can they be used to link libraries for example in index.html? (Probably not, because they are not found in the project folder).
我想我的问题是,除了我开头所说的之外,外部库的用途是什么?
I guess my question is what are the external libraries for, other than what I said in the beginning?
推荐答案
在 Settings/Languages&Frameworks/javaScript/Libraries 中配置的 Javascript 库(并在项目窗口中显示为外部库)与您的引用完全无关 标签.前者被 IDE 用于代码完成/导航/错误突出显示,后者在运行时被浏览器使用.浏览器对 IDE 中配置的 javascript 库一无所知,IDE 不会在 HTML 文件中使用
引用.
Javascript libraries configured in Settings/Languages&Frameworks/javaScript/Libraries (and shown as external libraries in the Project window) have absolutely nothing to do with references in your <script>
tag. The former are used by IDE for code completion/navigation/error highlighting, the latter are used by browser in runtime. The browser knows nothing about javascript libraries configured in IDE, the IDE doesn't use <script>
references in your HTML files.
让我试着把事情弄清楚:
Let me try to clear the things up:
应该使用哪些库:默认情况下,补全适用于位于项目根目录下的所有 JavaScript 文件.因此,如果您的项目结构中已经有库 .js 文件,则足以完成.如果它们丢失,并且您不喜欢用所有这些文件干扰您的项目,您可以将它们存储在外部(在您的项目之外)并将它们配置为库以使其可用于 WebStorm.另请注意,与项目中的 .js 文件相比,库是轻量级"的 - 它们被视为只读,并且检查已关闭.此外,您可以为它们分配文档 URL,从而为库代码启用外部文档.因此,即使您的项目中有库文件,将它们添加为库也是有意义的
What libraries are supposed to be used for: by default, completion works for all JavaScript files located under your project root. So, if you do already have the library .js files in your project structure, it's enough to get the completion. If they are missing, and you don't like to clatter your project with all these files, you can store them externally (outside of your project) and configure them as libraries to make them available to WebStorm. Note also that libraries are 'light-weight' as compared to .js files in your project - they are treated as read-only and have inspections turned off. Plus, you can assign documentation URLs to them, enabling external documentation for library code. So, even if you have your library files in your project, it might make sense to add them as libraries
总结一下:
库文件放置在项目中的源文件旁边结构对 WebStorm 和浏览器都可用,无论是否它们被添加到设置中的 javascript 库
library files placed next to your sources files in the project structure are available to both WebStorm and browser, whether or not they are added to javascript libraries in Settings
通过 HTML 中的 CDN 链接引用的在线库可用于浏览器在运行时,但不能用于完成
集成开发环境
online library referenced via CDN link in your HTML is available to
the browser at runtime, but can't be used for completion in the
IDE
一个放置在项目外部并配置为的库文件javascript 库将可用于 WebStorm 以完成,
但不会被浏览器加载
a library files placed outside of the project and configured as
javascript libraries will be available to WebStorm for completion,
but won't be loaded by a browser
这篇关于Webstorm 外部库说明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!