10分鐘快速配置sublime2支持jQuery開發
昨天介紹了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相當的方便。希望大家能喜歡這個編輯器 !
歡迎訪問GBin1.com


浙公網安備 33010602011771號