现在在手机客户端上Action Sheet非常常见,比如微信中的分享按钮菜单,下面我们使用jqMobi实现一个Action Sheet,如下:

小强的HTML5移动开发之路(38)——jqMobi插件ActionSheet

首先右击上面的按钮选择审查元素(我用的是Chrome浏览器,先按F12)

小强的HTML5移动开发之路(38)——jqMobi插件ActionSheet

然后Ctrl + F查找 showCustomHtmlSheet()方法

小强的HTML5移动开发之路(38)——jqMobi插件ActionSheet

代码贴出如下:

   function showCustomHtmlSheet() {
           $("#afui").actionsheet('<a  >Back</a><a  onclick="alert(\'hi\');" >Show Alert 3</a><a  onclick="alert(\'goodbye\');">Show Alert 4</a>');
   }
我们可以看到上面的函数中有三个按钮链接,上图中最后一个Cancel是系统默认的取消按钮。

再Ctrl + F查找一个 plugins,可以看到如下一行

好吧我们下面开始在我们的工程中实现如上效果:

首先引入af.actionsheet.css文件

小强的HTML5移动开发之路(38)——jqMobi插件ActionSheet

将上面的代码放入content中

<!DOCTYPE html> 
<html>
<head>
<meta charset="utf-8">
<title>jqMobi</title>
<link href="css/af.ui.css" rel="stylesheet" type="text/css"/>
<link href="css/icons.css" rel="stylesheet" type="text/css"/>
<link rel="stylesheet" type="text/css" href="plugins/css/af.actionsheet.css">
<script src="appframework.js" type="text/javascript"></script>
<script src="ui/appframework.ui.js" type="text/javascript"></script>
</head> 
<body> 
	<div >
        <div >
            <!-- any additional HTML you want can go here -->
            <a onclick="$.ui.toggleSideMenu();" class="button">Toggle Side Menu</a>
        </div>
        <div >
            <!-- this is where your panels will go -->
            <div >
               <a class="button" onclick="showCustomHtmlSheet()">Show Custom Html Sheet</a>
            </div>
            <div >
            <!-- by setting data-nav the "second_nav" will be shown on this panel -->
            </div>
        </div>
        //底部
        <div >
        <a target="#welcome" class="icon home">Home</a>
        </div>
    </div>
    <script>
		
		function showCustomHtmlSheet() {
			$("#afui").actionsheet('<a  >Back</a><a  onclick="alert(\'hi\');" >Show Alert 3</a><a  onclick="alert(\'goodbye\');">Show Alert 4</a>');
		}

                    
	</script>
</body>
</html>
运行结果:

小强的HTML5移动开发之路(38)——jqMobi插件ActionSheet




相关文章:

  • 2021-10-08
  • 2021-05-13
  • 2022-02-01
  • 2021-10-04
  • 2022-12-23
  • 2021-12-21
  • 2021-05-31
  • 2022-12-23
猜你喜欢
  • 2021-05-24
  • 2021-07-10
  • 2021-08-15
  • 2021-06-26
  • 2021-04-26
  • 2021-10-25
  • 2021-10-26
相关资源
相似解决方案