mui封装做好的手机版网站为apk
BOSS提到的一个功能,就是把已经做好的手机网站http://xxx.com/m/home/index ,想着看起来应该蛮简单,一个html页面里就一个iframe就好了,然后宽度和高度都设置为100%, 试了下,宽度没问题,就是高度的话100%是没有用的,试过在我的MX2手机上是可以100%撑开,钽是在同事的华为手机上又不能撑开了,上网搜索了一下,可以用JS来取得整个窗口的高度,下面是代码,直接写在MUI的新建 的项目中的INDEX.HTML页面就行了 <head> <meta charset="utf-8"> <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> <title></title> <style> * { margin: 0; padding: 0; } </style> <script type="text/javascript"> document.addEventListener('plusready', function() { //console.log("所有plus api都应该在此事件发生后调用,否则会出现plus is undefined。" // var h = plus.webview.currentWebview().height; 这是错的,取不到值 //console.log("当前页面URL:" + plus.webview.currentWebview().getURL() + " ,当前窗口高度:" + h); // document.getElementById('frm1').style.height = h + "px"; }); function setIframeHeight(iframe) { if(iframe) { var iframeWin = iframe.contentWindow || iframe.contentDocument.parentWindow; if(iframeWin.document.body) { iframe.height = iframeWin.document.documentElement.scrollHeight || iframeWin.document.body.scrollHeight; console.log("窗口高度:" + iframe.height); document.getElementById('frm1').style.height = iframe.height + "px"; } } }; window.onload = function() { setIframeHeight(document.getElementById('frm1')); }; </script> </head> <body> <iframe id="frm1" style="border:none;width:100%;height:100%;" src="http://baidu.com/"></iframe> </body>