在离子应用程序禁用硬件后退按钮?

编程入门 行业动态 更新时间:2024-10-25 16:23:04
本文介绍了在离子应用程序禁用硬件后退按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我试图禁用我的科尔多瓦应用程序中的后退按钮。我使用AngularJS +离子框架。我发现这个主题,并试图在code波纹管,但是它绝对没有任何影响。任何想法?谢谢!

I'm trying to disable the back button on my Cordova app. I'm using AngularJS + Ionic Framework. I found topics about this and tried the code bellow, but it has absolutely no effect. Any idea? Thanks!

index.html的

index.html

<head> <script> document.addEventListener("deviceready", onDeviceReady, false); function onDeviceReady() { document.addEventListener("backbutton", function (e) { e.preventDefault(); console.log("hello"); }, false ); } </script> </head>

请注意,当我按下后退按钮,我有你好显示在我的控制台。

Note that when I push back button, I have "hello" displayed in my console.

推荐答案

终于找到了对离子论坛线程答案:

Finally found the answer on Ionic Forum thread:

forum.ionicframework/t/handling-the-hardware-back-buttons/1505/7

$ionicPlatform.registerBackButtonAction(function () { if (condition) { navigator.app.exitApp(); } else { handle back action! } }, 100);

$ ionicPlatform.registerBackButtonAction允许完全地覆盖后退按钮行为。第一个参数是一个回调函数和secondone优先级(仅具有最高优先级被执行回调)。

$ionicPlatform.registerBackButtonAction allows to completly overwrite back button behavior. First param is a callback function and the secondone a priority (only the callback with the highest priority gets executed).

更多推荐

在离子应用程序禁用硬件后退按钮?

本文发布于:2023-11-24 18:56:04,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1626429.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:离子   应用程序   按钮   硬件

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!