HTML 5 前端架構jQuery Mobile使用教程

來源:互聯網
上載者:User

1. 簡介

jQuery Mobile是由(MT)Media Temple聯合多家行動裝置廠商以及軟體企業共同發起的針對觸屏智能手 機與平板電腦的Web應用的前端開發架構。

jQuery Mobile構建於大名鼎鼎的jQuery 以及 jQuery UI類庫之上,為前 端開發人員提供了一個相容所有主流行動裝置平台的統一UI介面系統。擁有出色的彈性,輕量化以及漸進增強特性與可訪問 性。

jQuery Mobile架構遵循"write less, do more"思想來設計,通過該架構,使用者可以開發跨平台、 跨裝置的統一的HTML5應用,無需針對每個裝置和作業系統分別開發應用代碼。目前jQuery Mobile支援的的系統和裝置有: iOS, Android, BlackBerry, Tizen, Bada, Windows Phone, WebOS, Symbian。

2. 下載和使用

jQuery Mobile強調語義標註,非常便於使用。只要會使用基本的HTML,就可以基於jQuery Mobile快速構建Web應用。目前JQuery Mobile最新的穩定版本為V1.2.0, 可以通過jQuery Mobile 官方網站http://jquerymobile.com/ 下載源碼。

jQuery Mobile使用非常簡單,開啟任何你所喜好的文字編輯器,建立一個檔案並命名為:test.html, 在該檔案開始處添加jQuery Mobile架構代碼:

<!DOCTYPE html>    <html>    <head>         <title>My Page</title>         <meta name="viewport" content="width=device-width, initial-scale=1">         <link rel="stylesheet" href="http://code.jQuery.com/mobile/1.2.0/jQuery.mobile-1.2.0.min.css" />         <script src="http://code.jQuery.com/jQuery-1.8.2.min.js"></script>         <script src="http://code.jQuery.com/mobile/1.2.0/jQuery.mobile-1.2.0.min.js"></script>    </head>    <body>    Add your content here.             </body>    </html>

儲存檔案,並在瀏覽器中開啟,即可瀏覽。

下面我們來實現一個Hello World例子, <body> 標籤中的內容用下面代碼替換。

<body>             <center data-role="page">                  <center data-role="header">             <h1>hello</h1>         </center><!-- /header -->                  <center data-role="content">               <p>Hello world</p>             </center><!-- /content -->             </center><!-- /page -->             </body>

在這段代碼中,我們首先使用一個data-role來描繪該頁面,同時使用hello作為我們的header data-role。在content標籤裡面,我們填入了<p>Hello world</p>。 這些特定的data-role定義的HTML5屬性 ,在JQuery Mobile中用於快速構建增強風格的使用者介面。

儲存代碼並在瀏覽器中開啟,效果如下:

圖1 Hello world運行效果

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.