如何在ionic3中隐藏键盘?
在iPhone上测试ionic 3应用程序时,我们遇到了一个问题。 在填写付款网关信息(在iFrame中启动)后,当我们使用返回按钮返回上一页时,键盘不会隐藏。
我们使用了cordova-plugin-ionic-keyboard并使用Keyboard.hide()方法,但没有起作用。
如何在ionic3中隐藏键盘?
在iPhone上测试ionic 3应用程序时,我们遇到了一个问题。 在填写付款网关信息(在iFrame中启动)后,当我们使用返回按钮返回上一页时,键盘不会隐藏。
我们使用了cordova-plugin-ionic-keyboard并使用Keyboard.hide()方法,但没有起作用。
使用键盘插件来操作 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();
试一下这个
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()