【发布时间】:2018-08-20 08:02:22
【问题描述】:
我想要一个离子输入,它会被聚焦并且不应该出现键盘。有什么办法或者有可能吗?谢谢!
【问题讨论】:
标签: ionic-framework ionic3 setfocus ionic-keyboard
我想要一个离子输入,它会被聚焦并且不应该出现键盘。有什么办法或者有可能吗?谢谢!
【问题讨论】:
标签: ionic-framework ionic3 setfocus ionic-keyboard
是的,安装这个插件 -> 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'?
我尝试了 Kevin 的回答,得到了与 Mitesh 相同的 'Keyboard' refers to a value, but is being used as a type here. Did you mean 'typeof Keyboard'? 问题。
我解决了这个问题:
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();
不确定如何或为什么需要这样做,但它对我有用。
【讨论】: