6

我想要一个离子输入,它会被聚焦并且键盘不应该出现。有什么办法或者有可能吗?谢谢!

4

2 回答 2

3

是的,安装这个插件-> 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();
      }
于 2018-08-20T09:21:55.087 回答
2

我尝试了凯文的答案,并得到了与'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();

不知道如何或为什么需要这样做,但它对我有用。

于 2020-07-26T14:41:21.073 回答