eclipse+spket+Extjs4.2.1開發環境搭建

來源:互聯網
上載者:User

標籤: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?

  1. <link rel="stylesheet" type="text/css" href="extjs-4.2.1/resources/css/ext-all.css">  // 引入樣式檔案  

  2. <script type="text/javascript" src="extjs-4.2.1/bootstrap.js" ></script>    

  3. <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?

  1. (function()  

  2.     {  

  3.      Ext.onReady(function()  

  4.      {  

  5.         Ext.Msg.alert("hello wrod!");  // 彈出hellowrod對話方塊 (執行個體化組 件)                                                                                 }                                                                                                                                                                                                                                                                                                                 }) ();   

                                                            
html代碼

 [html] view plaincopyprint?

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">  

  2. <html>  

  3. <head>  

  4. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">  

  5. <title>Insert title here</title>  

  6.   

  7.   

  8. <link rel="stylesheet"  type="text/css" href="./css/test.css">  

  9. <link rel="stylesheet"  type="text/css" href="./js/ext-4.2.1-gpl/resources/css/ext-all.css">//資源樣式檔案  

  10. <script type="text/javascript" src="./js/ext-4.2.1-gpl/bootstrap.js"></script>  

  11. <script type="text/javascript" src="./js/ext-4.2.1-gpl/locale/ext-lang-zh_CN.js"></script>//中文化  

  12. <script type="text/javascript" src="./js/helloword.js"></script>  

  13. </head>  

  14. <body>  

  15. </body>  

  16. </html>  

[javascript] view plaincopyprint?

  1. <pre code_snippet_id="170450" snippet_file_name="blog_20140125_1_6261797"></pre>  

  2. <pre></pre>  

  3. <pre></pre>  

  4. <pre></pre> 


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.