Fix:3952 【商城小程序】评论输入框跟随文本长度自适应变化

This commit is contained in:
LinCyJang
2025-07-06 22:35:50 +08:00
parent e8886a6050
commit 26cf65ee50
2 changed files with 60 additions and 18 deletions
+15 -6
View File
@@ -158,12 +158,15 @@
</view>
<view class="comment-input-wrap">
<view style="width: 100%;">
<u-input
<u-textarea
@focus="commentInputFocus"
@change="commentInputChange"
:prefixIcon="prefixIcon"
class="comment-input"
:showConfirmBar="false"
cursorSpacing="15"
v-model="reply"
autoHeight
placeholder="分享你的观点,让世界听见你的声音...">
<template slot="prefix">
@@ -177,7 +180,7 @@
></u--text>
</view>
</template>
</u-input>
</u-textarea>
</view>
<view class="">
<view class="send-btn v12-primary v12-white-text" @click="sendComment">发送</view>
@@ -234,10 +237,11 @@ export default {
this.currentComment = {}
return
}
const split = e.split(' ')
if(split[0] !== '' && this.currentComment.userNickName) {
// 若删除@用户名,将@用户名整个删除
const usernameLength = `@${this.currentComment.userNickName}`.length
if(!e.includes(`@${this.currentComment.userNickName}`) && this.currentComment.userNickName) {
this.currentComment = {}
return
this.reply = e.slice(usernameLength - 1); // 去除@用户名
}
},
commentInputFocus(e) {
@@ -246,7 +250,7 @@ export default {
selectComment(comment) {
this.currentComment = comment;
// this.prefixIcon = ''
this.reply = ' '
this.reply = '@' + comment.userNickName + ' '
},
/**
* 格式化时间
@@ -919,4 +923,9 @@ export default {
box-sizing: border-box;
}
}
.user-info{
view{
word-break: break-all;
}
}
</style>