手机显示数据的原理:手机通过WebView控件显示网页数据

WebView控件是用于显示网页的,手机根据网页创建一个WebView,之后显示出来,所以显示WebView网页是通过WebView控件显示的。

		<script type="text/javascript" charset="utf-8">
			mui.init();
			//mui加载完成事件
			mui.plusReady(function() {
				//定义子页面的数组
				var subPages = ["sub1.html", "sub2.html", "sub3.html", "sub4.html"];
				//定义子页面显示位置样式
				var subPageStyle = {
					top: "44px",//距离头部的距离
					bottom: "50px"//距离底部的距离
				}
				//获取主的webview
				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);返回webview對象
					//參數1:url,用於指定将哪个web页面创建为webview,
					//参数2:id,给每个web页面七个标识符,用于后面控制显示
					//参数3:style,设置样式
					var subView = plus.webview.create(url, url, subPageStyle)
					//默认设置每个子webview处于隐藏状态
					subView.hide();
					//为了主子webview同时显示,需要将每个子webview加入到主webview中
					mainView.append(subView);
				}
				//默认设置sub1.html子页面显示
				plus.webview.show(subPages[0])
			})
		</script>

猜你喜欢

转载自blog.csdn.net/qfxlw/article/details/83078448