Ionic 3条纹元素:当卡号完成并且焦点转到输入日期时,iOS键盘关闭

时间:2018-03-26 21:34:47

标签: angular ionic-framework stripe-payments

在Ionic应用程序上使用条纹元素输入卡片详细信息时,不能将键盘焦点保持在卡片输入字段上。

我在thread尝试了解决方案,但没有运气

这是我实施的代码

this.card = elements.create("card", { style });
this.card.focus();
setTimeout(() => {
  this.card.blur();
});

this.card.mount(this.cardInfo.nativeElement);

this.card.addEventListener("change", this.cardHandler);
// With element being a reference to the card element created by stripe.elements()
// or the CardElement component.
this.card.addEventListener("blur", ev => {
  // Apply only as a workaround for Safari on iOS,
  // else it will create an infinite loop on the `blur` event.
  if (
    navigator.userAgent.search("iPhone") != -1 &&
    navigator.userAgent.search("Version/") != -1
  ) {
    this.card.focus();
    this.card.blur();
  }

  // This is mandatory for all browsers
  this.card.getElementsByTagName("iframe")[0].blur();

0 个答案:

没有答案