首页 > 其他分享 >ionic3安卓触发返回键ion-datetime不自动关闭

ionic3安卓触发返回键ion-datetime不自动关闭

时间:2023-06-28 15:46:21浏览次数:64  
标签:返回 pickerClearButton 安卓 datetime ion 关闭

框架:ionic3 + angular
机型:安卓
问题:点击打开ion-datetime选择框,直接使用物理返回键(或自带的滑动返回)时,页面返回上一页但ion-datetime弹窗仍未关闭。
理想情况:返回时会自动关闭ion-datetime弹窗再返回上一页

image

解决方法:

// page.ts
import { Platform } from 'ionic-angular';
...
/ 监听物理返回按钮事件
    this.platform.registerBackButtonAction(() => {
      // 关闭datetime-picker
      var pickerClearButton = document.getElementsByClassName("picker-button")[0];
      if (pickerClearButton != undefined) {
        var clickEvent = new MouseEvent("click", {
          "view": window,
          "bubbles": true,
          "cancelable": false
        });
        pickerClearButton.dispatchEvent(clickEvent); // 触发关闭事件
      }
      this.navCtrl.pop(); // 返回上一页
    })

标签:返回,pickerClearButton,安卓,datetime,ion,关闭
From: https://www.cnblogs.com/zh1q1/p/17511512.html

相关文章

  • Python time和datetime模块
    Pythontime和datetime模块标准库time与datetime时间的3中格式:时间戳时间戳-->struct_timetime.gmtime(UTC时间)time.localtime(本地时区时间)struct_time()struct_time-->时间戳time.mktimestruct_time-->格式化的字......
  • spring mvc 支持options方法
    在web.xml中,添加<init-param> <param-name>dispatchOptionsRequest</param-name> <param-value>true</param-value> </init-param>添加后<servlet> <servlet-name>springdispatcher</servlet-name> <servle......
  • mysql collation 校对规则 utf8_general_ci 与 utf8_unicode_ci的区别
    援引官方文档 MysqldocumentForanyUnicodecharacterset,operationsperformedusingthe xxx_general_ci collationarefasterthanthoseforthe xxx_unicode_ci collation.Forexample,comparisonsforthe utf8_general_ci collationarefaster,butslightly......
  • java 序列化 serialVersionUID transient
    问题再现User类实现了序列化,但是没有声明版本号,这个对象放在memcache中,User新添加了1个字段后,把之前的对象从缓存中取出来时,出现了InvalidClassException,为什么会出现这个错误?序列化序列化就是将对象转为流,用于传输或保存。序列化的是“对象状态”,所以就不包括静态变量;反序列化是从......
  • java8 LocalDateTime/LocalDate/LocalTime、java.util.Date/java.sql.Date区别及日期
    先介绍一下,LocalDateTime/LocalDate/LocalTime、java.util.Date/java.sql.Date区别LocalDateTime/LocalDate/LocalTimejava.time.LocalDateTime,是一个日期+时间,不带时区,它是个不可更改对象,精确到纳秒。它的日期可以认为是生日,它的时间可以认为是挂钟的时间,比较LocalDateTime时用eq......
  • 同一个ip,不同端口号,session失效
    背景我有两个工程projectA、projectB,projectA放在TomcatA中,projectB放在TomcatB中,TomcatA、TomcatB在一台server上。工程都映射的根路径,不用project名字就可以访问,如下http://ip1:7777/http://ip1:8080/问题先在7777登录,然后再在8080登录,发现会把7777端口的用户踢下来;再在7777登......
  • Tomcat7 session 持久化
    tomcat7session默认是持久化的,tomcat7关闭或者重启,都会将内容持久化到SESSION.ser文件,这里推荐使用everything这个软件,查找这个文件。参考官方文档: 戳我......
  • .NET Core RSA 指南与增强扩展 RSAExtensions
    .NETCoreRSA指南与增强扩展RSAExtensions 一.前言#RSA作为最常用的非对称加密算法,在我们的实际使用中还是比较常见的,特别是对接支付十有八九都会遇到,或者是其他需要数据安全的业务场景。在.NETFramework以及.NETCore❤️.0时,.NET自带的RSA对象仅支持XML标准形......
  • ASCII = American Standard Code for Information Interchange
    Textonly语言:Ascii码表(全)ASCIITable(7-bit)(ASCII=AmericanStandardCodeforInformationInterchange) Decimal  Octal  Hex  Binary     Value-------  -----  ---  ------     ----- 000     000   00  00000000......
  • 使用 IntelliJ IDEA 开发 Azure Function APP (Java)
    使用IntelellJIDEA开发AzureFunctionAPP(Java)前提Azure账户并有可食用的订阅。创建免费的Azure账户。Azure支持的JavaDevelopmentKit(JDK),JDK8或JDK11。IntelliJIDEA无限制版本或社区版本均可。Maven3.5+最新的FunctionCoreTools安装插件并登......