源码,点导航栏上的“菜单”按钮,打开popovers,但被遮住了
<!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="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="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="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="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="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>
sunnidy
右上角的是在header父页面调用的弹出,但是没找到代码。太深奥了。demo能否易懂一点,不要隐藏的太深。
2015-04-16 18:05
DCloud_heavensoft
回复 sunnidy: 其实就是一个webview通知另一个webview弹出popover,popover是写在下面的webview里的,上面的webview是通过webview通信通知下面的webview,让下面那个弹出菜单
2015-04-17 02:17
sunnidy
回复 DCloud_heavensoft:我自己写了个webview的html页面使用plus.webview.create(url,id,{},{}).show()将页面弹出来了,在第二个json参数里面将弹出页面设置成非全屏(也就是不覆盖div.mui-content),然后自己在弹出的webview写了个遮罩层,效果是实现了,但是有以下三个问题:
1、我用的plus.webview.create(url,id,{},{}).show(),这个好像是预加载是不能传递参数给弹出页面的吧?如果要传递参数如何处理?
2、弹出webview的遮罩层,怎么设置透明?我找了公司的ui都没搞定,求教!
3、弹出页面的webview如何传递参数给父页面?难道也设置全局的js传递参数?
求教!
2015-04-17 23:03
DCloud_heavensoft
回复 sunnidy: webview之间的通信,使用evaljs方法,具体看webview的api。如果你用mui框架,可以参考这个文章,http://ask.dcloud.net.cn/docs/#http://ask.dcloud.net.cn/article/63。弹出半屏webview这个招有点大材小用了,比较消耗性能。还是建议搞明白webview之间的通信方法,从父webview通知子webview激活显示popover
2015-04-17 23:17
DCloud_UNI_FXY
回复 sunnidy:childWebview.evalJS('mui("#topPopover").popover("toggle")');
2015-04-17 23:28