Mui-tbar设置-流畅-先前一直用src跳转

<!doctype html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="css/mui.min.css" rel="stylesheet" />
	</head>
	<body>
		<header class="mui-bar mui-bar-nav">
		    <h1 class="mui-title">标题</h1>
		</header>
		
		<nav class="mui-bar mui-bar-tab">
		    <a class="mui-tab-item mui-active" href="show1.html">
		        <span class="mui-icon mui-icon-home"></span>
		        <span class="mui-tab-label">首页</span>
		    </a>
		    <a class="mui-tab-item" href="show2.html">
		        <span class="mui-icon mui-icon-phone"></span>
		        <span class="mui-tab-label">电话</span>
		    </a>
		    <a class="mui-tab-item" href="show3.html">
		        <span class="mui-icon mui-icon-email"></span>
		        <span class="mui-tab-label">邮件</span>
		    </a>
		    <a class="mui-tab-item" href="show4.html">
		        <span class="mui-icon mui-icon-gear"></span>
		        <span class="mui-tab-label">设置</span>
		    </a>
		</nav>
		<script src="js/mui.min.js"></script>
		<script src="js/jquery.min.js"></script>
		<script type="text/javascript">
			mui.init();
			//mui加载完成事件
			mui.plusReady(function(){
				//定义子页面的数组
				var subPages = ["show1.html","show2.html","show3.html","show4.html"];
				//定义子页面显示位置的样式
				var subPagesStyle = {
					top:"44px",//距离顶部44px
					bottom:"50px",
				};
				//获取主webview-也就是当前页面index
				var mainView = plus.webview.currentWebview();
				//遍历子页面数组,根据每个页面url创建webView
				for(var i=0;i<subPages.length;i++){
					var url = subPages[i];
					//创建webview参数plus.webview.create(url,id,style)(用于指定将那个web页面创建为webview,
					// 参数二,标识符,参数三设置样式)
					var subView = plus.webview.create(url,url,subPagesStyle);
					//设置子页面初始隐藏状态
					subView.hide();
					//将子页面追加到主页面
					mainView.append(subView);//处于隐藏
				}
				//默认第一个子页面显示
				plus.webview.show(subPages[0]);
				
				//给每个子页面tbr绑定点击事件,注意onclick,click是网页点击,手机无效
				mui(".mui-bar-tab").on("tap","a",function(){
					//获取点击的ID,href就可以当做ID,或者自己定义一个
					var id = this.getAttribute("href");
					plus.webview.show(id);
				});
				
			});
			
		</script>
	</body>

</html>

  

posted @ 2019-09-07 15:51  小白咚  阅读(278)  评论(0编辑  收藏  举报