这个移动应用程序是基于Onsen UI的,我正在尝试管理Android的后退和菜单按钮。所以我的问题被分成两部分。
首先,当用户点击设备的菜单按钮(尤其是三星)时,如何滑动应用程序的菜单?
第二个问题是关于移动设备的后退按钮(硬件),当点击它时,它存在应用程序,而它应该返回到主页,如果在主页上,客户端应该单击两次才能存在。
发布于 2016-04-01 08:09:07
我相信Onsen团队在他们的论坛上回答了你关于but按钮的问题,但对于其他人来说,这里有一些资源:
使用Onsen的后退按钮只会发出popPage。如果没有要弹出的页面,它将退出应用程序。有关控制该行为的详细信息,请参阅以下内容:
https://onsen.io/guide/overview.html#HandlingBackButton
ons.setDefaultDeviceBackButtonListener(function() {
if (navigator.notification.confirm("Are you sure to close the app?",
function(index) {
if (index === 1) { // OK button
navigator.app.exitApp(); // Close the app
}
}
));
});对于菜单按钮,您只需要添加一个事件监听器:
document.addEventListener("menubutton", onMenuKeyDown, false);
function onMenuKeyDown() {
// Handle the back button
}https://cordova.apache.org/docs/en/latest/cordova/events/events.menubutton.html
https://stackoverflow.com/questions/36322371
复制相似问题