Bel*_*liF 7 typescript ionic2 ionic3 angular
我想自定义此屏幕截图中提到的后退按钮的单击操作.我希望通过点击我不会返回到上一页,而是返回到我自己指定的页面,或者在返回之前进行处理.
Ari*_*ora 14
对于自定义默认后退按钮操作,您需要覆盖NavBar组件的backButtonClick()方法.
第1步:在"custom-class.ts"中 导入Navbar组件.创建auxMethod以覆盖默认行为并在ionViewDidLoad方法中调用.
import { Navbar } from 'ionic-angular';
import { ViewChild } from '@angular/core';
export class myCustomClass {
@ViewChild(Navbar) navBar: Navbar;
ionViewDidLoad() {
this.setBackButtonAction()
}
//Method to override the default back button action
setBackButtonAction(){
this.navBar.backButtonClick = () => {
//Write here wherever you wanna do
this.navCtrl.pop()
}
}
}
Run Code Online (Sandbox Code Playgroud)
此代码已在离子3中进行了测试.
| 归档时间: |
|
| 查看次数: |
5275 次 |
| 最近记录: |