我已经在mui.init中把所有的滑动事件全部取消监听了,可是实际情况并没有,我从左边缘向右滑动时,依然可以起到返回的作用,而正巧,我的第一个页面是登录页面,这就不好了,望高手指点啊
<!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" />
<link rel="stylesheet" href="css/mui.ustc.css" />
<script src="js/mui.min.js"></script>
<script src="js/update.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<header class="mui-bar mui-bar-nav">
<h1 class="mui-title">模拟手机平台</h1>
</header>
<script>
var menu = null,
list = null,
main = null;
var showMenu = false;
mui.init({
swipeBack: false,
statusBarBackground: '#0E83F8',
subpages: [{
id: 'home',
url: 'page/home.html',
styles: {
top: '45px',
bottom: 0,
bounce: 'vertical'
}
}],
gestureConfig:{
tap: false,
doubletap: false,
longtap: false,
swipe: false,
drag: false,
hold:false,
release:false
}
});
mui.plusReady(function() {
if (mui.os.android) {
plus.screen.lockOrientation("portrait-primary");
}
main = plus.webview.currentWebview();
main.addEventListener('maskClick', closeMenu);
//处理侧滑导航,为了避免和子页面初始化等竞争资源,延迟加载侧滑页面;
setTimeout(function() {
menu = mui.preload({
id: 'index-menu',
url: 'index-menu.html',
styles: {
left: 0,
width: '70%',
zindex: -1
},
show: {
aniShow: 'none'
}
});
}, 200);
});
/**
* 显示侧滑菜单
*/
function openMenu() {
if (!showMenu) {
//侧滑菜单处于隐藏状态,则立即显示出来;
menu.show('none', 0, function() {
//主窗体开始侧滑并显示遮罩
main.setStyle({
mask: 'rgba(0,0,0,0.4)',
left: '70%',
transition: {
duration: 150
}
});
showMenu = true;
});
}
}
/**
* 关闭菜单
*/
function closeMenu() {
if (showMenu) {
//关闭遮罩;
//主窗体开始侧滑;
main.setStyle({
mask: 'none',
left: '0',
transition: {
duration: 200
}
});
showMenu = false;
//等动画结束后,隐藏菜单webview,节省资源;
setTimeout(function() {
menu.hide();
}, 300);
}
}
//点击左上角侧滑图标,打开侧滑菜单;
document.querySelector('.mui-icon-bars').addEventListener('tap', function() {
if (showMenu) {
closeMenu();
} else {
openMenu();
}
});
//主界面向右滑动,若菜单未显示,则显示菜单;否则不做任何操作
//window.addEventListener("swiperight", openMenu);
//主界面向左滑动,若菜单已显示,则关闭菜单;否则,不做任何操作;
window.addEventListener("swipeleft", closeMenu);
//侧滑菜单触发关闭菜单命令
window.addEventListener("menu:close", closeMenu);
window.addEventListener("menu:open", openMenu);
//重写mui.menu方法,Android版本menu按键按下可自动打开、关闭侧滑菜单;
mui.menu = function() {
if (showMenu) {
closeMenu();
} else {
openMenu();
}
}
//处理右上角关于图标的点击事件;
var subWebview = null,
template = null;
document.getElementById('info').addEventListener('tap', function() {
if (subWebview == null) {
//获取共用父窗体
template = plus.webview.getWebviewById("default-main");
subWebview = template.children()[0];
}
subWebview.loadURL('examples/info.html');
//修改共用父模板的标题
mui.fire(template, 'updateHeader', {
title: '关于',
showMenu: false
});
template.show('slide-in-right', 150);
});
//首页返回键处理
//处理逻辑:1秒内,连续两次按返回键,则退出应用;
var first = null;
mui.back = function() {
if (showMenu) {
closeMenu();
} else {
//首次按键,提示‘再按一次退出应用’
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>
</html>
iOS (作者)
感谢,效果杠杠的
2015-02-01 12:21
没豆
我用了怎么么有效果呢??
2015-05-25 14:33
l***@163.com
没有效果
2016-11-01 12:51