[英]Is there any way to hide keyboard when focusing an ion-input?
我想要一個離子輸入,它會被聚焦並且鍵盤不應該出現。 有什么辦法或者有可能嗎? 謝謝!
是的,安裝這個插件 -> https://ionicframework.com/docs/native/keyboard/
html
<ion-input type="text" [(ngModel)]="message" (ionFocus)="keyboard_show()" #input ></ion-input>
ts
import {
Keyboard
} from '@ionic-native/keyboard';
constructor(private keyboard: Keyboard, private ) {
}
keyboard_show(){
this.keyboard.close();
}
我嘗試了凱文的回答,得到了相同的'Keyboard' refers to a value, but is being used as a type here. Did you mean 'typeof Keyboard'?
'Keyboard' refers to a value, but is being used as a type here. Did you mean 'typeof Keyboard'?
Mitesh 得到的問題。
我解決了這個問題:
import { Keyboard } from '@ionic-native/keyboard/ngx'
@Component({
selector: 'app-upload-root',
templateUrl: 'upload-root.page.html',
styleUrls: ['upload-root.page.scss'],
providers: [Keyboard]
})
constructor(private keyboard: Keyboard)
this.keyboard.hide();
不確定如何或為什么需要這樣做,但它對我有用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.