昨天介绍了javascript的开发工具sublime 2 edit,今天我们将介绍如何10分钟快速配置sublime2支持jQuery开发。希望大家能喜欢着款jQuery开发工具。
相关介绍:使用sublime text 2开发Javacript和jQuery
安装Sublime 2
Sublime2下载地址:http://www.sublimetext.com/download
安装jQuery插件
jQuery插件下载地址:https://github.com/mrmartineau/jQuery
安装配置jQuery插件包
以上俩个都是zip包。先解压sublime2的压缩包,因为我使用WIN7,所以,下载了64位的zip包。解压后,如下:
Sublime Text 2 Build 2139 x64
解压后,先找到sublime_text.exe,然后点击运行。会看到目录下生成一个新的data文件夹,将你下载的jQuery文件,解压后,直接拷贝到如下目录:
<dirrectory to unzip>\Sublime Text 2 Build 2139 x64\Data\Packages
然后,重启sublime 2编辑器。
Sublime 2 界面如下:
看到编辑器界面后,请按快捷键:Ctrl + Shift + P,然后输入jQuery, 这样缺省编辑器使用jQuery的语法和自动方法补齐。
输入如下:
$.ready
按Tab键,可以看到编辑器让你选择代码片段类型,分别对应如下三段代码片段:
$.jQuery(document).ready(function($) {
// Stuff to do as soon as the DOM is ready. Use $() w/o colliding with other libs;
});
$.jQuery(document).ready(function() {
// Stuff to do as soon as the DOM is ready;
});
$.$(document).ready(function() {
// Stuff to do as soon as the DOM is ready;
});
以上是ready的代码,你可以选择3种代码片段中的一种。
如果你输入$.ajax 后按下Tab键,生成如下代码片段:
$.ajax({
url: '/path/to/file',
type: 'POST',
dataType: 'xml/html/script/json/jsonp',
data: {param1: 'value1'},
complete: function(xhr, textStatus) {
//called when complete
},
success: function(data, textStatus, xhr) {
//called when successful
},
error: function(xhr, textStatus, errorThrown) {
//called when there is an error
}
});
怎么样,很不错吧,虽然稳定性还有待提高,但是编辑jQuery相当的方便。希望大家能喜欢这个编辑器 !