nicks
nicks
  • 发布:2015-04-15 18:12
  • 更新:2015-04-16 09:32
  • 阅读:3043

请教 父webview 的popovers 被子 webview的类容遮住了,请教大神解惑,新手

分类: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>  

    <link href="http://ask.dcloud.net.cn/css/mui.min.css" rel="stylesheet" />  
    <style>  
        body {  
            background-color: #F6F6F6;  
        }  

        #topPopover {  
            position: fixed;  
            top: 16px;  
            right: 6px;  
        }  
        #topPopover .mui-popover-arrow {  
            left: auto;  
            right: 6px;  
        }  
        p {  
            text-indent: 22px;  
        }  
        span.mui-icon {  
            font-size: 14px;  
            color: #007aff;  
            margin-left: -15px;  
            padding-right: 10px;  
        }  
        .mui-popover {  
            height: 300px;  
        }  
        .mui-content {  
            padding: 10px;  
        }  
    </style>  

</head>  

<body>  
    <header class="mui-bar mui-bar-nav">  
        <h1 class="mui-title">【湘江钓鱼人】</h1>  
        <h1 class="mui-title">  
            <img src="images/myico.png" style="margin-left: 120px; margin-top: 5px;width: 30px;height: 30px;" />  
        </h1>  
        <a href="#topPopover" class="mui-btn mui-btn-link mui-pull-right">菜单</a>  
    </header>  

    <nav class="mui-bar mui-bar-tab">  
        <a id="defaultTab" class="mui-tab-item mui-active" href="http://ask.dcloud.net.cn/exa/shouye.html">  
            <span class="mui-icon mui-icon-chatbubble"><span class="mui-badge">5</span></span>  
            <span class="mui-tab-label">最新资讯</span>  
        </a>  
        <a class="mui-tab-item" href="http://ask.dcloud.net.cn/exa/wdquanzi.html">  
            <span class="mui-icon mui-icon-pengyouquan"><span class="mui-badge">35</span></span>  
            <span class="mui-tab-label">我的圈子</span>  
        </a>  
        <a class="mui-tab-item" href="http://ask.dcloud.net.cn/exa/faxian.html">  
            <span class="mui-icon mui-icon-search"><span class="mui-badge">15</span></span>  
            <span class="mui-tab-label">发现</span>  
        </a>  
        <a class="mui-tab-item" href="http://ask.dcloud.net.cn/exa/me.html">  
            <span class="mui-icon mui-icon-contact"><span class="mui-badge">25</span></span>  
            <span class="mui-tab-label">我</span>  
        </a>  
    </nav>  

    <!--弹出菜单-->  
        <div id="topPopover" class="mui-popover">  
            <ul class="mui-table-view">  
                <li class="mui-table-view-cell"><a href="#">Item2</a>  
                </li>  
                <li class="mui-table-view-cell"><a href="#">Item3</a>  
                </li>  
                <li class="mui-table-view-cell"><a href="#">Item4</a>  
                </li>  
                <li class="mui-table-view-cell"><a href="#">Item5</a>  
                </li>  
                <li class="mui-table-view-cell"><a href="#">Item6</a>  
                </li>  
                <li class="mui-table-view-cell"><a href="#">Item7</a>  
                </li>  
                <li class="mui-table-view-cell"><a href="#">Item8</a>  
                </li>  
                <li class="mui-table-view-cell"><a href="#">Item9</a>  
                </li>  
                <li class="mui-table-view-cell"><a href="#">Item的发生份10</a>  
                </li>  
            </ul>  
        </div>  

</body>  
<script src="js/mui.min.js"></script>  
<script src="js/app.js"></script>  
<script>  
    mui.init();  
     //     右上角弹出菜单  
    mui('body').on('shown', '.mui-popover', function(e) {  
        //console.log('shown', e.detail.id);//detail为当前popover元素  
    });  
    mui('body').on('hidden', '.mui-popover', function(e) {  
        //console.log('hidden', e.detail.id);//detail为当前popover元素  
    });  
     //分页导航  
    var subpages = ['exa/shouye.html', 'exa/wdquanzi.html', 'exa/faxian.html', 'exa/me.html'];  
    var subpage_style = {  
        top: '46px',  
        bottom: '50px'  
    };  
     //创建子页面,首个选项卡页面显示,其它均隐藏;  
    mui.plusReady(function() {  
        var self = plus.webview.currentWebview();  
        for (var i = 0; i < 4; i  ) {  
            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;  
        }  
        //更换标题  
        //title.innerHTML = this.querySelector('.mui-tab-label').innerHTML;  
        //显示目标选项卡  
        plus.webview.show(targetTab);  
        //隐藏当前;  
        plus.webview.hide(activeTab);  
        //更改当前活跃的选项卡  
        activeTab = targetTab;  
    });  
     //自定义事件,模拟点击“首页选项卡”  
    document.addEventListener('gohome', function() {  
        var defaultTab = document.getElementById("defaultTab");  
        //模拟首页点击  
        mui.trigger(defaultTab, 'tap');  
        //切换选项卡高亮  
        var current = document.querySelector(".mui-bar-tab>.mui-tab-item.mui-active");  
        if (defaultTab !== current) {  
            current.classList.remove('mui-active');  
            defaultTab.classList.add('mui-active');  
        }  
    });  
</script>  

</html>

2015-04-15 18:12 负责人:无 分享
已邀请:
DCloud_UNI_FXY

DCloud_UNI_FXY

把popover放在子webview。父webview通知子webview进行显示,隐藏

  • nicks (作者)

    谢谢

    请问 父webview通知子webview进行显示,隐藏的那行代码如何写?

    不好意思,初学者

    2015-04-15 18:49

nicks

nicks (作者)

谢谢
请问 父webview通知子webview进行显示,隐藏的那行代码如何写?
不好意思,初学者

DCloud_UNI_FXY

DCloud_UNI_FXY

参考hello-mui中的popovers.html示例代码

子webview.evalJS('mui("#popover").popover('toggle');');

nicks

nicks (作者)

报了个错
Uncaught TypeError: Cannot call method ’toggle‘ of undefined

我的代码:

//当前激活选项
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;
}
//更换标题
//title.innerHTML = this.querySelector('.mui-tab-label').innerHTML;
//显示目标选项卡
plus.webview.show(targetTab);
//隐藏当前;
plus.webview.hide(activeTab);
//更改当前活跃的选项卡
activeTab = targetTab;
});

    ********//测试方法--打开下拉菜单  
    document.getElementById("sh").addEventListener("tap",function(){  
        plus.webview.getWebviewById(activeTab).evalJS('mui("#topPopover").popover().toggle();');  

    });
  • DCloud_UNI_FXY

    前边回复错了,应该是:子webview.evalJS('mui("#popover").popover("toggle");');

    2015-04-16 00:30

nicks

nicks (作者)

非常感谢

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