uniapp编译多端项目App、小程序,input框键盘输入后

项目场景:

uniapp编译后的小程序端,app端 在一个输入框 输入消息后,点击键盘上的操作按钮之后键盘不被收起,点击其他发送按钮时,键盘也不被收起。


问题描述

在编译后的app上普通的事件绑定,@tap,@click在发送事件上,每次点击发送后,input框就失焦了,键盘就被收起了。


解决方案:

因为uniapp有编译成app和小程序,就有两端的解决方案,app和小程序不兼容

小程序端:

需要设置:hold-keyboard,confirm-hold 这两个属性为true,hold-keyboard只兼容小程序。

文档:input | uni-app官网

html 复制代码
<input
 :confirm-hold="true"
 :hold-keyboard="true"
 ref="inputEle"
class="TUI-message-input-area"
:adjust-position="false"
cursor-spacing="20"
v-model="inputText"
@input="onInputValueChange"
maxlength="140"
type="text"
placeholder-class="input-placeholder"
placeholder="说点什么呢~"
@focus="inputBindFocus"
	@blur="inputBindBlur"
/>

app端:

需要把发送按钮的@tap事件改为@touchend.prevent绑定,confirm-hold这两个属性为true

html 复制代码
<input
:confirm-hold="true"
ref="inputEle"
class="TUI-message-input-area"
:adjust-position="true"
cursor-spacing="20"
v-model="inputText"
@input="onInputValueChange"
maxlength="140"
type="text"
placeholder-class="input-placeholder"
placeholder="说点什么呢~"
/>
<view  class="TUI-sendMessage-btn" @touchend.prevent="sendTextMessage">发送</view>
相关推荐
眨眼猫会务智能体8 小时前
眨眼猫会务智能体会务系统的服务响应怎么样?出问题多久有人接?
安全·小程序·会务
微订校园外卖平台8 小时前
校园跑腿小程序上线:四端架构与校园外卖系统履约链路拆解
小程序·架构·外卖系统·本地生活·微订
蒿豪郝灬号9 小时前
UniApp接入鸿蒙版阿里百川
华为·uni-app·harmonyos
m0_5873830020 小时前
广州 24 小时自助健身房解决方案技术实现与实战指南
java·spring·小程序·架构·需求分析
迪飞特科技1 天前
智慧物业平台实战:Spring Boot 整合小程序实现报修巡检费用全流程
spring boot·后端·小程序
m0_587383001 天前
无人自助拼豆系统从需求分析到落地部署全流程实战开发指南
java·经验分享·后端·struts·小程序·架构·需求分析
小小王app小程序开发1 天前
DIY水晶小程序玩法开发功能分析
小程序
andrsted1 天前
练题簿在线免费刷题:顺序续练、优先新题与题型筛选,让复习一轮轮推进
微信小程序·小程序·刷题
2501_915921431 天前
详细教程:使用Perfdog工具测量iOS应用的功耗性能与优化方法
android·macos·ios·小程序·uni-app·cocoa·iphone
梦曦i1 天前
uni-app、uni-app x 与 Flutter 深度对比:2026年跨平台开发框架选型指南
flutter·uni-app·uni-app x