小白请指教
小白请指教
  • 发布:2025-10-23 10:37
  • 更新:2025-10-23 10:39
  • 阅读:11

【报Bug】nvue下textarea 做聊天偶然在没有换行符的情况下会触发发送信息

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: w10

HBuilderX类型: 正式

HBuilderX版本号: 4.66

手机系统: iOS

手机系统版本号: iOS 26

手机厂商: 苹果

手机机型: apple iPhone 15 Pro Max

页面类型: nvue

vue版本: vue2

打包方式: 云端

项目创建方式: HBuilderX

示例代码:
<textarea id='textarea' class="textarea" :class="{'nobg':!tipsShow.fenpei}" maxlength="199" :placeholder="tipsShow.fenpei?localeLang('请输入聊天内容...'):localeLang('正在分配客服中...')" cursor-spacing="30" ref='focuess' :auto-blur="false" :confirm-hold="true" :focus="chatFocus" :disabled="!tipsShow.fenpei" show-confirm-bar='false' :value="chatValue" @input="chatWrite($event)" @focus="chatFocusChange($event);popupLayerOpen=false" @blur="chatBlurChange()"
@confirm="clickBarSend()" confirm-type="send"
@keyboardheightchange="chatKeyboardHeightChange($event)" auto-height />

watch: {
chatValue(txt) {
if (/\n$/.test(txt)) { //敲了回车键了
this.clickBarSend()
this.chatValue = ''
}
}
},
//发送信息
clickBarSend(){
},
chatFocusChange: function(e) {
let that = this
if (that.popupLayerOpen == true) {
// setTimeout(function(){
that.popupLayerOpen = false
that.heizj = 1
that.scrollHeight=that.scrollHeight uni.upx2px(190)
// that.scrollHeight=that.scrollHeight uni.upx2px(190)
// },300)
that.$forceUpdate()
}
that.chatFocus=true
// #ifdef APP-PLUS
this.keyboardHeight = e.detail.height;
if(this.emojiOpen ){
this.topHeight=e.detail.height-150
}else{
this.topHeight=e.detail.height
}
// #endif
setTimeout(function() {
const el = that.$refs.listBottom
dom.scrollToElement(el, {})
}, 0)
},
//失去焦点
chatBlurChange: function(e) {
let that = this
if (that.heizj) {
// that.scrollHeight = that.scrollHeight - uni.upx2px(190)
setTimeout(function() {
that.scrollToBottom();
}, 0);
}
this.heizj = ''
that.chatFocus=false
this.keyboardHeight = 0;
this.topHeight=0

            setTimeout(function() {  
                const el = that.$refs.listBottom  
                dom.scrollToElement(el, {})  
            }, 100)  
        },  
        //编辑消息  
        chatWrite: function(e) {  
            this.chatValue = e.detail.value;  
            let that=this,bhgd=0  
            var query = uni.createSelectorQuery().in(this);    
            query.select('#textarea').boundingClientRect();    
            query.exec(data => {    
                bhgd=data[0].height-that.srkgd  
                if(that.srkgd!=0){  
                    that.scrollHeight=that.scrollHeight - bhgd  
                    setTimeout(function() {  
                        that.scrollToBottom();  
                    }, 0);  
                }  
                that.srkgd=data[0].height  
            });  

        }

操作步骤:

在输入文字的时候 偶然会发送出去信息

预期结果:

点击发送在发送

实际结果:

偶然会自动发送

bug描述:

nvue下textarea 做聊天偶然在没有换行符的情况下会触发发送信息

2025-10-23 10:37 负责人:无 分享
已邀请:
小白请指教

小白请指教 (作者) - 小白一个

nvue文件无法上传 改为txt上传代码

要回复问题请先登录注册