From 7f5cf72d4670b00be9d509d5ad3bd3504e746cf1 Mon Sep 17 00:00:00 2001 From: liuyalei Date: Thu, 7 Mar 2024 13:28:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8D=E5=85=81=E8=AE=B8=E7=BC=A9=E6=94=BE?= =?UTF-8?q?=20=E5=AE=89=E5=8D=93=E9=94=AE=E7=9B=98=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 3 ++- src/views/IndexChat.vue | 30 +++++++++++++++++++++++------- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/index.html b/index.html index 379b6fb..f6a1884 100644 --- a/index.html +++ b/index.html @@ -3,8 +3,9 @@ + - + 优享地图 diff --git a/src/views/IndexChat.vue b/src/views/IndexChat.vue index 5fd2b7c..a7b3840 100644 --- a/src/views/IndexChat.vue +++ b/src/views/IndexChat.vue @@ -255,14 +255,14 @@ -
+
-
@@ -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) => {