小韩
小韩
  • 发布:2016-07-06 11:42
  • 更新:2017-12-15 10:21
  • 阅读:2550

窗口切换显示卡顿-底部选项卡-webview模式

分类:MUI

魅族 m1 metal
主要想实现底部点击窗口切换,官方提供的又不能记录滚动条

<body>  
        <nav id="defaultTab"  class="mui-bar mui-bar-tab">  
            <a class="mui-tab-item mui-active" href="tab-webview-subpage-about.html" data-id='home'>  
                <span class="mui-icon mui-icon-home"></span>  
                <span class="mui-tab-label">首页</span>   
            </a>  
            <a class="mui-tab-item" href="tab-webview-subpage-chat.html" data-id="chat">  
                <span class="mui-icon mui-icon-email"><span class="mui-badge">9</span></span>  
                <span class="mui-tab-label">消息</span>  
            </a>  
            <a class="mui-tab-item" href="tab-webview-subpage-contact.html" data-id="contact">  
                <span class="mui-icon mui-icon-contact"></span>  
                <span class="mui-tab-label">通讯录</span>  
            </a>    
            <a class="mui-tab-item" href="tab-webview-subpage-setting.html" data-id="setting">  
                <span class="mui-icon mui-icon-gear"></span>  
                <span class="mui-tab-label">设置</span>  
            </a>  
        </nav>  
        <script src="js/mui.min.js"></script>  
        <script type="text/javascript" charset="utf-8">   
             mui.init();  
            mui.plusReady(function() {  
                var aniShow = {};  
                var self = plus.webview.currentWebview();  
                var current = '';  
                var styles = {  
                    top: '45px',  
                    bottom: '51px'  
                };   
                var tabsConfig = {  
                    home: {  
                        url: 'tab-webview-subpage-about.html',  
                        styles: styles,  
                        default: true  
                    },  
                    chat: {  
                        url: 'tab-webview-subpage-chat.html',  
                        styles: styles  
                    },  
                    contact: {  
                        url: 'tab-webview-subpage-contact.html',  
                        styles: styles  
                    },  
                    setting: {  
                        url: 'tab-webview-subpage-setting.html',  
                        styles: styles  
                    }  
                };  
                var tabs = {};  
                for (id in tabsConfig) {  
                    tabs[id] = plus.webview.create(tabsConfig[id].url, id, tabsConfig[id].styles);  
                    if (tabsConfig[id]['default']) {  
                        self.append(tabs[id]);  
                        var temp = {};  
                        temp[id] = "true";  
                        current = id;   
                        mui.extend(aniShow,temp);   
                    }  
                }  

                mui('#defaultTab').on('tap', 'a', function(e) {  

                    if (current == this.dataset.id) {  
                        mui.fire(tabs[current], 'scroll2top');  
                        return;  
                    }   
                    tabs[current].hide();  
                    if(aniShow[this.dataset.id]){  
                        tabs[this.dataset.id].show();  
                    }else{  
                        //否则,使用fade-in动画,且保存变量  
                        var temp = {};  
                        temp[this.dataset.id] = "true";  
                        mui.extend(aniShow,temp);   
                        tabs[this.dataset.id].show('fade-in',200);  
                    }  

                    current = this.dataset.id;  
                });  
            });  

            var first = null;  
            mui.back = function() {  
              //首次按键,提示‘再按一次退出应用’  
                    if (!first) {  
                        first = new Date().getTime();  
                        mui.toast('再按一次退出应用');  
                        setTimeout(function() {  
                            first = null;  
                        }, 1000);  
                    } else {  
                        if (new Date().getTime() - first < 1000) {  
                            plus.runtime.quit();  
                        }  
                    }  
            };  

        </script>  
    </body>
2016-07-06 11:42 负责人:无 分享
已邀请:
8***@qq.com

8***@qq.com

这一样写跳转的时候感觉好生硬

java屌丝

java屌丝 - 90IT

为什么不在单个webview关闭或者隐藏前重写事件

Mr_zhu

Mr_zhu

为什么要每次创建页面 这种页面可以用预加载 控制显示隐藏就好了

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