在 ionic 4 中覆盖工具栏后退按钮操作



in Ionic 3 可以通过navbar.backButtonClick = ()=>{}覆盖后退按钮操作

自 Navbar 以来,Ionic 4 中不再存在 NavController

什么是

类似的为什么覆盖ion-back-button返回操作

您可以在AppComponent类上使用以下代码。

this.platform.backButton.subscribeWithPriority(9999, () => {
    // You decide what happens 
});

我的朋友,这样它就可以工作了.. 安卓和 iOS 哈哈哈

<ion-header>
    <ion-toolbar>
        <ion-buttons slot="start" style="position: relative;">
            <ion-back-button></ion-back-button>
            <div (click)="backButtonClick()" style="position: absolute;left: 0;top: 0;width: 100%;height: 100%;background-color: transparent;z-index: 1000;"></div>
        </ion-buttons>
    </ion-toolbar>
</ion-header>

最新更新