如何将 Jquery 添加到 Sublime Text 2?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11925927/
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
How to add Jquery to Sublime Text 2?
提问by Michael
This may sound stupid.
这听起来可能很愚蠢。
But how do you add Jquery to sublime text 2?
但是如何将 Jquery 添加到 sublime text 2 中呢?
Can't seem to get it working.
似乎无法让它工作。
I've added thisgithub.
我已经添加了这个github。
Then created a Jquery folder in my packages.
然后在我的包中创建了一个 Jquery 文件夹。
Finally I added this into my head tags.
最后,我将其添加到我的 head 标签中。
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
But still no luck.
但仍然没有运气。
采纳答案by Valjas
Sublime Text 2 uses JavaScript syntax for supporting jQuery. In looking at the Github repo you tried, I'm assuming you're wanting some sort of a snippet library. I'd recommend this instead: https://github.com/aaronpowell/sublime-jquery-snippetsand/or https://github.com/SublimeText/jQuery.
Sublime Text 2 使用 JavaScript 语法来支持 jQuery。在查看您尝试过的 Github 存储库时,我假设您想要某种代码片段库。我建议改为:https://github.com/aaronpowell/sublime-jquery-snippets和/或https://github.com/SublimeText/jQuery。
To clarify something else for you, adding:
为您澄清其他事情,添加:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
Adds the jQuery library to your HTML page so you can use its methods and functions. It doesn't add it to Sublime Text 2, but nonetheless it is necessary for the aforementioned reason.
将 jQuery 库添加到您的 HTML 页面,以便您可以使用其方法和函数。它没有将它添加到 Sublime Text 2,但由于上述原因,它仍然是必要的。
回答by dicentiu
first add Package Control to Sublime Text. This is accessed via the ctrl+` shortcut. Once open, paste the code from hereinto the console and hit Enter.
首先将 Package Control 添加到 Sublime Text。这是通过 ctrl+` 快捷方式访问的。打开后,将此处的代码粘贴到控制台中,然后按 Enter。
Go to Preferences > Package Control > from that list click on Package Control Install Packagethen search for jQuery. This will install jQuery.
转到 Preferences > Package Control > 从该列表中单击Package Control Install Package然后搜索 jQuery。这将安装 jQuery。
Now, if you want autocompletion for jQuery follow these steps:
现在,如果您想要 jQuery 的自动完成功能,请按照以下步骤操作:
- Domnload this: package from github
- Extract the content in a place you can access it quickly, look for the file “AndyjQuery.sublime-completions”.
- Not sure if it will work just placing the file with the current name, so I renamed it as “jQuery.sublime-completions”
- Place this file in the folder jQuery from the location that opens when you go to Preferences - Browse Packages
- Domnload 这个:来自 github 的包
- 将内容提取到您可以快速访问的位置,查找文件“AndyjQuery.sublime-completions”。
- 不确定它是否可以仅放置具有当前名称的文件,所以我将其重命名为“jQuery.sublime-completions”
- 将此文件从您转到首选项 - 浏览包时打开的位置放在 jQuery 文件夹中
if you want to use autocompletion when pressing the dot: Go to Preferences - Settings User and add this
如果您想在按下点时使用自动完成功能:转到首选项 - 设置用户并添加此项
"auto_complete_triggers": [ {"selector": "source.js", "characters": "."} ],
"auto_complete_triggers": [ {"selector": "source.js", "characters": "."} ],