標籤:style blog http color java 使用 os io
一、開發工具配置
1、http://www.eclipse.org/downloads/下載Eclipse,解壓。 2、http://spket.com/download.html下載Plugin,解壓後覆蓋到Eclipse的目錄。 3、啟動Eclipse,選擇window→proference→spket→javascriptprofiles→new (輸入Ext JS4.2.1)
4、Add libary(選擇ExtJS)。
5、Add file(選擇ext-all-dev.js),注意整個路徑不能出現中文。
6、選中Ext JS 4.2.1,設定預設。
7、將 js預設開啟檔案設為 spket。(如果不成功,請重複檢查上面的步驟,重點檢查第6步,設定預設成功之後字型明顯變黑)
8、重啟Eclipse。 9、建立javascript檔案,輸入Ext+. 則會出現自動提示
如果沒有出現自動提示則右擊你的JS檔案,有個Open with - 選擇spket JavaScript Editor。 如果仍舊沒有出現提示則可以通過在專案檔上點擊右鍵,選擇“Reload Javascript Profiles”菜單,對javascript檔案重新載入。
二、ExtJS開發環境搭建: (1) 下載Ext開發包,:http://extjs.org.cn/ (2) 將Ext開發包copy到eclipse項目的/WebRoot目錄下 注意:不需要整個Ext開發包全部匯入,這樣很容易造成eclipse卡死,因為eclipse會自動檢測js的合法性,會佔用大量的檢測時間、cpu和記憶體。通常普通的開發只需要用到\extjs-4.2.1\resources檔案包、\extjs-4.2.1\ext-all.js這兩個資源就可以,需要中文化再匯入\extjs-4.2.1\locale\ext-lang-zh_CN.js 就可以了
(3) 在web頁面中通過<script>標籤引入ext的庫檔案。(注意引入順序)
Extjs4.0開始比以往有些變化,用起來麻煩不小。與以前的引入三個檔案不同,現在的4.0隻要引用兩個檔案就行了。
[javascript] view plaincopyprint?
-
<link rel="stylesheet" type="text/css" href="extjs-4.2.1/resources/css/ext-all.css"> // 引入樣式檔案
-
<script type="text/javascript" src="extjs-4.2.1/bootstrap.js" ></script>
-
<script type="text/javascript" src="ext-4.2.1/locale/ext-lang-zh_CN.js"></script> // 中文化
(4) 調用Ext.onReady()初始化組件
<script>
Ext.onReady(function(){
…///在這裡面建立及使用ext控制項
});
</script>
三、hello word 執行個體
hellowrod.js
[javascript] view plaincopyprint?
-
(function()
-
{
-
Ext.onReady(function()
-
{
-
Ext.Msg.alert("hello wrod!"); // 彈出hellowrod對話方塊 (執行個體化組 件) } }) ();
html代碼
[html] view plaincopyprint?
-
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-
<html>
-
<head>
-
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
-
<title>Insert title here</title>
-
-
-
<link rel="stylesheet" type="text/css" href="./css/test.css">
-
<link rel="stylesheet" type="text/css" href="./js/ext-4.2.1-gpl/resources/css/ext-all.css">//資源樣式檔案
-
<script type="text/javascript" src="./js/ext-4.2.1-gpl/bootstrap.js"></script>
-
<script type="text/javascript" src="./js/ext-4.2.1-gpl/locale/ext-lang-zh_CN.js"></script>//中文化
-
<script type="text/javascript" src="./js/helloword.js"></script>
-
</head>
-
<body>
-
</body>
-
</html>
[javascript] view plaincopyprint?
-
<pre code_snippet_id="170450" snippet_file_name="blog_20140125_1_6261797"></pre>
-
<pre></pre>
-
<pre></pre>
-
<pre></pre>