<view class="oper flex-row" @tap.prevent.stop="" :style="'bottom:'+keyHeight+'px;'">
<!--语音切换-->
<image v-if="isEdit" @tap="toggleEdit(false)" src="../../../static/img/voice-circle.png" class="icon">
</image>
<image v-else @tap="toggleEdit(true)" src="../../../static/img/keyboard.png" class="icon"></image>
<!--输入框-->
<textarea v-if="isEdit" @focus="inputFocus" :focus="isFocus" :cursor-spacing="8" :adjust-position="false"
v-model="content" class="input" placeholder="请输入内容" maxlength="-1" auto-height></textarea>
<view v-else @touchstart="startVoice" @touchend="endVoice" @touchmove.stop.prevent="voiceIng"
@touchcancel="voiceCancel" class="input" style="text-align: center;font-weight: 700;">{{ voiceTis }}
</view>
<!--表情-->
<image @tap="togglePicker(200, 'emoji')" src="../../../static/img/emoji.png" class="icon"></image>
<!--发送-->
<view @touchend.prevent="send" v-show="content" class="btn">发送</view>
<!--附件-->
<image @tap="togglePicker(86, 'file')" v-show="!content" src="../../../static/img/add.png" class="icon">
</image>
</view>
使用textarea输入多行文本时会自动向下扩展,这里给外层oper加上固定定位:style="'bottom:'+keyHeight+'px;'使其在原位置保持不变并向上扩展
// 监听输入聚焦获取高度
inputFocus(e) {
this.setScrollHeight(e.detail.height)
this.keyHeight = e.detail.height
this.initScrollBar()
uni.onKeyboardHeightChange(res => {
this.setScrollHeight(res.height)
this.keyHeight = res.height
this.initScrollBar()
})
},
提交的内容显示不换行解决方法
.pre-text {
white-space: pre-wrap;
}