@@ -308,6 +308,10 @@ const cksend = (val) => {
}
}
+const handleInputFocus = () => {
+ console.log("聚焦了");
+ scollToButtom();
+}
const sendMessage = () => {
console.log("信息发送成功", inputText.value);
let messageValue = inputText.value.trim()
@@ -370,12 +374,24 @@ const goke = () => {
const bookDoctor = () => {
location.href = 'https://wx.nbgzjk.cn/#/home'
};
+// const scollToButtom = () => {
+// nextTick(() => {
+// let chatForm = document.getElementById('chatform'); // 获取对象
+// if (chatForm) {
+// chatForm.scrollTop = chatForm.scrollHeight+99999; // 滚动高度
+// console.log("滚动",chatForm.scrollTop);
+// }
+// });
+// }
const scollToButtom = () => {
nextTick(() => {
- let chatForm = document.getElementById('chatform'); // 获取对象
- if (chatForm) {
- chatForm.scrollTop = chatForm.scrollHeight; // 滚动高度
- }
+ setTimeout(() => { // 增加延迟等待页面布局调整
+ let chatForm = document.getElementById('chatform');
+ if (chatForm) {
+ chatForm.scrollTop = chatForm.scrollHeight - chatForm.clientHeight; // 调整滚动逻辑
+ console.log("滚动", chatForm.scrollTop);
+ }
+ }, 300); // 延迟时间可以根据实际情况调整
});
}
/* watch(inputText, (newValue, oldValue) => {