本文介绍了温泉UI:控制研究机器人后退按钮路线:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在开发使用Onsenui在科尔多瓦的Android应用程序,其中我要的是点击设备后退按钮时,浏览到previous页
我使用的答案从问题,解决问题。
下面是我的code
document.addEventListener(后退按钮,onBackButton pressed,FALSE);
功能onBackButton pressed(){
警报('后退按钮');
VAR元= document.querySelector(.navigator容器);
VAR范围= angular.element(元素).scope();
scope.popPage();
}
我会收到以下错误
解决方案
Probably .navigator-container
has been deprecated, that's why I suggest you to get the navigator by using ons-navigator
as argument for document.querySelector()
.
Here is the fixed code:
document.addEventListener("backbutton",onBackButtonPressed, false);
function onBackButtonPressed(){
alert('backbutton');
var element = document.querySelector("ons-navigator");
element.popPage();
}
EDIT
Supposing that you are using an older version of Onsen UI, like 1.3.4, and supposing that your navigator has a var='myNavigator'
attribute, you can use the following code:
document.addEventListener("backbutton",onBackButtonPressed, false);
function onBackButtonPressed(){
alert('backbutton');
var element = document.querySelector("ons-navigator");
var scope = angular.element(element).scope();
scope.myNavigator.popPage();
}
这篇关于温泉UI:控制研究机器人后退按钮路线:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!