HTML5移動開發之路(38)——jqMobi外掛程式ActionSheet

來源:互聯網
上載者:User

標籤:it教育   標籤   html5   開發   機構   

本文為 兄弟連IT教育 機構官方 HTML5培訓 教程,主要介紹:HTML5移動開發之路(38)——jqMobi外掛程式ActionSheet

現在在手機用戶端上Action Sheet非常常見,比如中的分享按鈕菜單,下面我們使用jqMobi實現一個Action Sheet,如下:

650) this.width=650;" src="http://img.blog.csdn.net/20140123174830000?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvZGF3YW5nYW5iYW4=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" style="border:0px;" />

首先右擊上面的按鈕選擇審查元素(我用的是Chrome瀏覽器,先按F12)

650) this.width=650;" src="http://img.blog.csdn.net/20140123175115375?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvZGF3YW5nYW5iYW4=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" style="border:0px;" />

 

[html] view plain copy

 

 print?650) this.width=650;" src="https://code.csdn.net/assets/CODE_ico.png" alt="在CODE上查看代碼片" width="12" height="12" style="border:0px;" />650) this.width=650;" src="https://code.csdn.net/assets/ico_fork.svg" alt="派生到My Code片" width="12" height="12" style="border:0px;" />

  1. <a class="button" onclick="showCustomHtmlSheet()">Show Custom Html Sheet</a>  

 

然後Ctrl + F尋找 showCustomHtmlSheet()方法

650) this.width=650;" src="http://img.blog.csdn.net/20140123175357750?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvZGF3YW5nYW5iYW4=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" style="border:0px;" />

代碼貼出如下:

 

[javascript] view plain copy

 

 print?650) this.width=650;" src="https://code.csdn.net/assets/CODE_ico.png" alt="在CODE上查看代碼片" width="12" height="12" style="border:0px;" />650) this.width=650;" src="https://code.csdn.net/assets/ico_fork.svg" alt="派生到My Code片" width="12" height="12" style="border:0px;" />

  1. function showCustomHtmlSheet() {  

  2.         $("#afui").actionsheet(‘<a  >Back</a><a  onclick="alert(\‘hi\‘);" >Show Alert 3</a><a  onclick="alert(\‘goodbye\‘);">Show Alert 4</a>‘);  

  3. }  

我們可以看到上面的函數中有三個按鈕連結,中最後一個Cancel是系統預設的取消按鈕。

 

再Ctrl + F尋找一個 plugins,可以看到如下一行

 

[html] view plain copy

 

 print?650) this.width=650;" src="https://code.csdn.net/assets/CODE_ico.png" alt="在CODE上查看代碼片" width="12" height="12" style="border:0px;" />650) this.width=650;" src="https://code.csdn.net/assets/ico_fork.svg" alt="派生到My Code片" width="12" height="12" style="border:0px;" />

  1. <link rel="stylesheet" type="text/css" href="plugins/css/af.actionsheet.css">  

 

好吧我們下面開始在我們的工程中實現如上效果:

首先引入af.actionsheet.css檔案

650) this.width=650;" src="http://img.blog.csdn.net/20140123180207890?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvZGF3YW5nYW5iYW4=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" style="border:0px;" />

將上面的代碼放入content中

 

[html] view plain copy

 

 print?650) this.width=650;" src="https://code.csdn.net/assets/CODE_ico.png" alt="在CODE上查看代碼片" width="12" height="12" style="border:0px;" />650) this.width=650;" src="https://code.csdn.net/assets/ico_fork.svg" alt="派生到My Code片" width="12" height="12" style="border:0px;" />

  1. <!DOCTYPE html>   

  2. <html>  

  3. <head>  

  4. <meta charset="utf-8">  

  5. <title>jqMobi</title>  

  6. <link href="css/af.ui.css" rel="stylesheet" type="text/css"/>  

  7. <link href="css/icons.css" rel="stylesheet" type="text/css"/>  

  8. <link rel="stylesheet" type="text/css" href="plugins/css/af.actionsheet.css">  

  9. <script src="appframework.js" type="text/javascript"></script>  

  10. <script src="ui/appframework.ui.js" type="text/javascript"></script>  

  11. </head>   

  12. <body>   

  13.     <div id="afui">  

  14.         <div id="header">  

  15.             <!-- any additional HTML you want can go here -->  

  16.             <a onclick="$.ui.toggleSideMenu();" class="button">Toggle Side Menu</a>  

  17.         </div>  

  18.         <div id="content">  

  19.             <!-- this is where your panels will go -->  

  20.             <div id="main" title="Welcome" class="panel" selected="true">  

  21.                <a class="button" onclick="showCustomHtmlSheet()">Show Custom Html Sheet</a>  

  22.             </div>  

  23.             <div id="about" title="About" class="panel" data-nav="second_nav">  

  24.             <!-- by setting data-nav the "second_nav" will be shown on this panel -->  

  25.             </div>  

  26.         </div>  

  27.         //底部  

  28.         <div id="navbar">  

  29.         <a target="#welcome" class="icon home">Home</a>  

  30.         </div>  

  31.     </div>  

  32.     <script>  

  33.           

  34.         function showCustomHtmlSheet() {  

  35.             $("#afui").actionsheet(‘<a  >Back</a><a  onclick="alert(\‘hi\‘);" >Show Alert 3</a><a  onclick="alert(\‘goodbye\‘);">Show Alert 4</a>‘);  

  36.         }  

  37.   

  38.                       

  39.     </script>  

  40. </body>  

  41. </html>  

運行結果:

 

650) this.width=650;" src="http://img.blog.csdn.net/20140123181009500?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvZGF3YW5nYW5iYW4=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" style="border:0px;" />


HTML5移動開發之路(38)——jqMobi外掛程式ActionSheet

聯繫我們

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