坛子
坛子
  • 发布:2014-11-11 17:10
  • 更新:2014-11-11 18:11
  • 阅读:3159

主页面嵌套子页面后,点击子页面button按钮导致子页面闪动

分类:MUI

代码如下:当点击子页面的登录按钮,子页面就会闪动

主页面:

<!DOCTYPE html>  
<html>  

    <head>  
        <meta charset="utf-8">  
        <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />  
        <title></title>  
        <script src="js/mui.min.js"></script>  
        <link href="http://ask.dcloud.net.cn/css/mui.min.css" rel="stylesheet" />  
        <script type="text/javascript" src="js/jquery-2.1.1.min.js"></script>  
    </head>  

    <body>  
        <header class="mui-bar mui-bar-nav">  
            <a id="zt_d" class="mui-icon mui-icon-info-filled mui-pull-right" style="color: #999;"></a>  
            <h1 class="mui-title">首页</h1>  
        </header>  

        <script charset="UTF-8">  
            mui.init({  
                swipeBack: true,  
                subpages: [{  
                    id: 'login',  
                    url: 'login.html',  
                    styles: {  
                        top: '48px',  
                        bottom: 0,  
                        bounce: 'vertical'  
                    }  
                }]  
            });  

            document.getElementById("zt_d").addEventListener('tap', function() {  
                console.log("ds");  

            });  

            mui.plusReady(function() {  
                //首页返回键处理  
                //处理逻辑:1秒内,连续两次按返回键,则退出应用;  
                var first = null;  
                plus.key.addEventListener('backbutton', function() {  
                    //首次按键,提示‘再按一次退出应用’  
                    if (!first) {  
                        first = new Date().getTime();  
                        mui.toast('再按一次退出应用');  
                        setTimeout(function() {  
                            first = null;  
                        }, 1000);  
                    } else {  
                        if (new Date().getTime() - first < 1000) {  
                            plus.runtime.quit();  
                        }  
                    }  
                }, false);  
            });  
        </script>  
    </body>  

</html>

子页面:

<!DOCTYPE html>  
<html>  

    <head>  
        <meta charset="utf-8">  
        <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />  
        <title></title>  
        <script src="js/mui.min.js"></script>  
        <link href="http://ask.dcloud.net.cn/css/mui.min.css" rel="stylesheet" />  
    </head>  

    <body style="background-color:#E2E2E2;">  
        <div align="center" style="width:100%;padding:10%;">  
            <img src="img/icon.png" width="50%" />  
        </div>  
        <form class="mui-input-group">  
            <div class="mui-input-row">  
                <label>用户:</label>  
                <input type="text" placeholder="请输入用户名">  
            </div>  
            <div class="mui-input-row">  
                <label>密码:</label>  
                <input type="password" placeholder="请输入密码">  
            </div>  
            <div class="mui-input-row mui-checkbox mui-left">  
                <label>记住密码</label>  
                <input name="checkbox" type="checkbox">  
            </div>  

            <div style="padding:10%;">  
                <button class="mui-btn mui-btn-primary mui-btn-block" id="submit">登 录</button>  
            </div>  

        </form>  

        <script>  
            mui.init();  
            document.getElementById("submit").addEventListener('tap',function(){  
                console.log("测试!");  
            });  
        </script>  
    </body>  
</html>
2014-11-11 17:10 负责人:无 分享
已邀请:
DCloud_UNI_CHB

DCloud_UNI_CHB

始终为button按钮添加type属性,否则默认type类型为submit,当将button放在form中时,点击button会触发form表单提交,你会感觉闪一下。

该问题目前已经被锁定, 无法添加新回复