Ionic2 更改离子导航栏背面按钮行为离子2
我想更改“后退”按钮的行为,而不是返回上一页,它将执行其他操作。可能吗Ionic2 更改离子导航栏背面按钮行为离子2,ionic2,Ionic2,我想更改“后退”按钮的行为,而不是返回上一页,它将执行其他操作。可能吗 <ion-navbar> <ion-title center>Mobile Apps</ion-title> </ion-navbar> 移动应用 如果(condition==true){//保持在 第}页其他{//返回上一页} 您可以使用: 在某些情况下,开发人员应该能够控制视图的离开和关闭 套房。为了实现这一点,NavController具有IonVie
<ion-navbar>
<ion-title center>Mobile Apps</ion-title>
</ion-navbar>
移动应用
如果(condition==true){//保持在
第}页其他{//返回上一页}
您可以使用:
在某些情况下,开发人员应该能够控制视图的离开和关闭
套房。为了实现这一点,NavController具有IonViewCanCenter和
ionViewCanLeave方法。类似于有棱角的2个路线守卫,但
更集成导航控制器。例如,如果你想
防止用户离开视图:
@MohanGopi,我想改变back按钮的行为,而不是返回到上一页,它会做一些其他的事情,这可能会帮助你,你需要做什么?将用户重定向到其他页面,防止用户离开,…@sebafereras,它将基于条件if(condition==true){//留在页面上}否则{//返回上一页}完美!谢谢。很高兴听到这对@Parth:)有帮助
export class MyClass {
constructor(public navCtrl: NavController){}
ionViewCanLeave(): boolean{
// here we can either return true or false
// depending on if we want to leave this view
if(isValid(randomValue)){
return true;
} else {
return false;
}
}
}