繁体   English   中英

硬件后退按钮被调用两次 ionic5

[英]hardware back button is called twice ionic5

我尝试配置硬件后退按钮并在其中调用一个函数:


import { Platform } from '@ionic/angular';
constructor(private platform: Platform) {
  this.platform.backButton.subscribeWithPriority(10, () => {
    //call my function here
  });
}

但是当我点击按钮时,它会被调用两次。我正在使用 ionic5。 有任何想法吗?

You can try async and await as follow

import { Platform } from '@ionic/angular';
    constructor(private platform: Platform) {
      this.platform.backButton.subscribeWithPriority(10, async () => {
        await this.functionCall() // Your function call goes here
      });
    }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM