在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();