angular - 我无法处理 Ionic 4 上的 android 后退按钮
问题描述
我是离子开发的新手。我通过以下文章尝试了越来越多的方法。最后,我在 Ionic3 Vs Ionic4 中尝试了这个处理硬件后退按钮, 请帮助我@Fabian N。
但是在设备上,我看不出后退按钮是否与代码有关……那是代码在我的情况下不起作用。:(
这是我的离子信息。
Ionic:
Ionic CLI : 5.2.3 (/usr/local/lib/node_modules/ionic)
Ionic Framework : @ionic/angular 4.6.2
@angular-devkit/build-angular : 0.13.9
@angular-devkit/schematics : 7.3.9
@angular/cli : 7.3.9
@ionic/angular-toolkit : 1.5.1
Cordova:
Cordova CLI : 9.0.0 (cordova-lib@9.0.1)
Cordova Platforms : android 8.0.0, ios 5.0.1
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 4.1.1, (and 16 other plugins)
Utility:
cordova-res : not installed
native-run : 0.2.8
System:
ios-deploy : 1.9.4
ios-sim : 8.0.1
NodeJS : v11.10.1 (/usr/local/bin/node)
npm : 6.7.0
OS : macOS Mojave
Xcode : Xcode 10.2 Build version 10E125
我已经在app.component.ts
. 但是单击后退按钮时,我无法在真实设备上收到任何警报。
1. Test case
this.platform.backButton.subscribe(async () => {
alert("Fired Back Button");
});
2. Test case
this.platform.backButton.subscribe(() => {
alert("Fired Back Button");
});
3. test case
this.platform.backButton.subscribeWithPriority(0, () => {
alert("Fired Back Button");
});
4. test case
this.platform.backButton.subscribeWithPriority(100, () => {
alert("Fired Back Button");
});
在这种情况下 4,我尝试了诸如优先级:100、101、400、999999。但是单击 android 后退按钮时我无法收到任何警报。
但实际上后退按钮总是弹出页面。
我只需要在我的项目上处理 android 硬件后退按钮。请帮我。先感谢您。此致
解决方案
推荐阅读
- google-chrome-extension - 仅在一台主机上启用 Chrome 扩展操作按钮
- java - Spring Boot 无法读取某些 API 响应
- excel - 在excel中创建树视图/动态表并过滤空白
- sql - 如何将数据相乘以获得价值 | 甲骨文 |
- python - Python SVM OVO 打破关系
- reactjs - “无法读取未定义的属性‘地图’”
- blazor - 将文件从 javascript 发送到 blazor
- python - 如何重构 Python pandas Dataframe,优化
- sqlalchemy - sqlalchemy.dialects:“突触”。pyodbc
- apache-camel - 为什么我们的应用程序中需要 Apache Camel?