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>
  • 相关阅读:
    PostGIS常用SQL
    PostGIS相关数据类型及内置函数介绍
    基于GeoTools做GeoJson,PostGIS,Shapefile的转换
    如何使用GeoTools
    JavaScript 循环
    jquery 层级选择器
    jquery 表单选择
    js 字符串操作
    js对象
    js函数 作用域 闭包 回调
  • 原文地址:https://www.cnblogs.com/beast-king/p/9115028.html
Copyright © 2011-2022 走看看