zoukankan      html  css  js  c++  java
  • mui---mui.preload预加载后的几种显示方法

    preload_home.html(预加载的首页)

    <!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>
            <button type="button" id="btn_open">打开预加载的页面</button>
            <script src="js/mui.min.js"></script>
            <script type="text/javascript">
                mui.init();
                var page = null;
                mui.plusReady(function() {
                    //预加载页面mui.preload必须放在plusReady事件中
                    page = mui.preload({
                        url: 'preload_sub.html',
                        id: 'preload_sub',
                        extras: {
                            name: 'durant'
                        }
                    });
    
                })
                
                
                document.getElementById("btn_open").addEventListener('tap', function() {
                    //预加载仅会提前创建webview,并不会默认打开,因此需要再使用mui.openWindow方法打开对应窗口,才会看到预加载效果。
                    if(page) {
                        //方法1:直接调用预加载页面对象page的show方法
                        //page.show();
    
                        //方法2:mui.openWindow
                        //mui.openWindow('preload_sub');//简写,通过ID打开指定页面
                        mui.openWindow({
                            url: 'preload_sub.html',
                            id: 'preload_sub'
                        }) //亦可写详细的参数
    
                        //方法3:getWebviewById(),通过ID找到webview,再调用show()方法
                        //var wv = plus.webview.getWebviewById('preload_sub'); //请在plus ready后再调用plus api,不一定非得写在plusReady事件中
                        //console.log(page == wv) //true,page就是'preload_sub'所对应的webview
                        //wv.show();
                    }
                })
            </script>
        </body>
    
    </html>

     

    preload_sub.html(预加载的页面)

    <!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>
            <div id="div1"></div>
            <script src="js/mui.min.js"></script>
            <script type="text/javascript">
                mui.init();
                //            window.onload=function(){
                mui.plusReady(function() {
                    var self = plus.webview.currentWebview();
                    document.getElementById("div1").innerText = 'hi,' + self.name;
                })
                //            }
            </script>
        </body>
    
    </html>
  • 相关阅读:
    PAT (Advanced Level) Practice 1071 Speech Patterns (25分)
    PAT (Advanced Level) Practice 1070 Mooncake (25分)
    PAT (Advanced Level) Practice 1069 The Black Hole of Numbers (20分)
    PAT (Advanced Level) Practice 1074 Reversing Linked List (25分)
    PAT (Advanced Level) Practice 1073 Scientific Notation (20分)
    第一次冲刺个人总结01
    构建之法阅读笔记01
    人月神话阅读笔记01
    四则运算2
    学习进度条(软件工程概论1-8周)
  • 原文地址:https://www.cnblogs.com/beast-king/p/9115028.html
Copyright © 2011-2022 走看看