【问题标题】:Ionic3 keep keyboard after send messageIonic3在发送消息后保留键盘
【发布时间】:2018-01-11 14:27:00
【问题描述】:

我在 Ionic3 页面中有以下 html 来实现聊天:

  <ion-item>
    <ion-textarea placeholder="Write your message" [(ngModel)]="newMessage"></ion-textarea>
    <button ion-button clear item-right icon-only (click)="sendMessage()">
      <ion-icon name="paper-plane"></ion-icon>
    </button>
  </ion-item>

我想保持设备键盘显示,直到用户按下设备“后退按钮”或在 ion-textarea 元素之外。我尝试过使用 ionFocus 和 ionBlur 事件。

有什么想法吗?

【问题讨论】:

    标签: angular ionic-framework keyboard textarea ionic3


    【解决方案1】:

    你需要把它放在你的 config.xml 中用于 IOS 设备

    <preference name="KeyboardDisplayRequiresUserAction" value="false" />
    

    或者在 Android 中,您需要在函数调用时像这样防止默认:

     (mousedown)="$event.preventDefault()"
    

    【讨论】:

    • 我已经试过了。它不起作用,在我单击 sendMessage 按钮后键盘关闭。我正在 Android 设备上运行该应用程序。也许 只适用于 IOS?
    • 是的,此偏好适用于 IOS 设备,您使用的是 android 吗?
    • 把这个添加到你的发送按钮也许:(mousedown)="$event.preventDefault(); sendMessage($event)" 我希望对你有帮助:)
    • 是的,安卓设备
    • 发送消息时,e.preventDefault();将防止自动更改,如键盘关闭
    猜你喜欢
    • 2018-10-31
    • 2013-03-11
    • 1970-01-01
    • 1970-01-01
    • 2016-12-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-02-13
    相关资源
    最近更新 更多