如何在Ionic 3中隐藏键盘?

3

如何在ionic3中隐藏键盘?

在iPhone上测试ionic 3应用程序时,我们遇到了一个问题。 在填写付款网关信息(在iFrame中启动)后,当我们使用返回按钮返回上一页时,键盘不会隐藏。

我们使用了cordova-plugin-ionic-keyboard并使用Keyboard.hide()方法,但没有起作用。


这回答解决了你的问题吗?有没有办法在聚焦ion-input时隐藏键盘? - Liam Ferris
2个回答

2

使用键盘插件来操作 Cordova:

import { Keyboard } from '@ionic-native/keyboard/ngx'; 

...

constructor(private keyboard: Keyboard) { }

...

this.keyboard.show(); 
this.keyboard.hide();

如果您正在使用Capacitor(推荐):

import { Plugins, KeyboardInfo } from '@capacitor/core';    
const { Keyboard } = Plugins;

...

Keyboard.show();   
Keyboard.hide();

0

试一下这个

import { Keyboard } from '@ionic-native/keyboard';

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {
 constructor(public navCtrl: NavController, public keyboard : Keyboard) {
  }
}

然后在返回按钮上使用这个

this.keyboard.close()

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接