的所发生的
的所发生的
  • 发布:2016-03-15 16:13
  • 更新:2016-03-16 01:18
  • 阅读:1303

怎么实现webView模式的选项卡啊?

分类:MUI
<!DOCTYPE html>  
<html>  

    <head>  
        <meta charset="utf-8">  
        <title>Hello MUI</title>  
        <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">  
        <meta name="apple-mobile-web-app-capable" content="yes">  
        <meta name="apple-mobile-web-app-status-bar-style" content="black">  

        <link rel="stylesheet" href="css/mui.min.css">  
        <script src="js/mui.min.js"></script>  
        <style>  
            html,  
            body {  
                background-color: #efeff4;  
            }  
        </style>  
    </head>  

    <body>  
        <header class="mui-bar mui-bar-nav">  
            <a class="mui-icon  mui-pull-right" style="color: #999;"></a>  
            <h1 class="mui-title" id="title">解放军医院</h1>  
        </header>  
        <nav class="mui-bar mui-bar-tab">  
            <a id="defaultTab" class="mui-tab-item mui-active" href="tab-index.html">  
                <span class="mui-icon mui-icon-home"></span>  
                <span class="mui-tab-label">首页</span>  
            </a>  
            <a class="mui-tab-item" href="tab-survey.html">  
                <span class="mui-icon mui-icon-star"></span>  
                <span class="mui-tab-label">医院概况</span>  
            </a>  
            <a class="mui-tab-item" href="tab-contact.html">  
                <span class="mui-icon mui-icon-map"></span>  
                <span class="mui-tab-label">联系我们</span>  
            </a>  
            <a class="mui-tab-item" href="tab-myorder.html">  
                <span class="mui-icon mui-icon-gear"></span>  
                <span class="mui-tab-label">我的预约</span>  
            </a>  
        </nav>  

        <script>  
            mui.init();  
            mui.back = function() {  
                var btn = ["确定", "取消"];  
                mui.confirm('确认关闭当前窗口?', 'Hello MUI', btn, function(e) {  
                    if (e.index == 0) {  
                        mui.currentWebview.close();  
                    }  
                });  
            }  

            var menu = null,  
                list = null,  
                mask = null;  
            var showMenu = false;  
            var subpages = ['tab-index.html', 'tab-survey.html', 'tab-contact.html', 'tab-myorder.html'];  
            var subpage_style = {  
                top: '46px',  
                bottom: '50px'  
            };  
            mui.plusReady(function() {  
                // 隐藏滚动条  
                plus.webview.currentWebview().setStyle({  
                    scrollIndicator: 'none'  
                });  

                //当前的webview对象,应该为一个只有头和尾的  
                var self = plus.webview.currentWebview();  
                for (var i = 0; i < 4; i++) {  
                    //创建多个子的页面webview对象  
                    var sub = plus.webview.create(subpages[i], subpages[i], subpage_style);  
                    if (i > 0) {  
                        sub.hide();  
                    }  
                    self.append(sub);  
                }  
            });  
             //当前激活选项  
            var activeTab = subpages[0];  
            var title = document.getElementById("title");  
             //选项卡点击事件  
            mui('.mui-bar-tab').on('tap', 'a', function(e) {  
                var targetTab = this.getAttribute('href');  
                if (targetTab == activeTab) { //点击的当前活动的不处理  
                    return;  
                } else {  
                    //更换标题  
                    var tname = this.querySelector('.mui-tab-label').innerHTML;  

                    if (tname == "首页") {  
                        tname = "解放军医院";  
                    }  
                    title.innerHTML = tname;  
                    //显示目标选项卡  
                    plus.webview.show(targetTab, "auto");  
                    //隐藏当前;  
                    plus.webview.hide(activeTab);  
                    //更改当前活跃的选项卡  
                    activeTab = targetTab;  
                }  
            });  
        </script>  
    </body>  

</html>
2016-03-15 16:13 负责人:无 分享
已邀请:
好冷

好冷 - 诚接外包,QQ:23380891

js改样式咯,无非是多个mui-active的事

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