فهرست منبع

聊天界面,每次出现新消息,滚动条滚动到最新位置

maxiaoxiao 11 ماه پیش
والد
کامیت
ecd0e95c90
1فایلهای تغییر یافته به همراه8 افزوده شده و 11 حذف شده
  1. 8 11
      src/views/aiModel/index.vue

+ 8 - 11
src/views/aiModel/index.vue

@@ -3,7 +3,7 @@
     <div class="counsel-header">
       <span>会话<i class="ai el-icon-chat-dot-round"></i></span>
     </div>
-    <div class="counsel-chats" ref="scrollContainer" @scroll="handleScroll">
+    <div class="counsel-chats" ref="scrollRef">
       <div class="counsel-left flex">
         <div class="header-img">
           <img src="/static/images/aiModel/kefu.png" />
@@ -101,6 +101,7 @@ export default {
   },
   created() {},
   mounted() {},
+
   methods: {
     initSpeech() {
       // 检查浏览器是否支持SpeechRecognition
@@ -264,16 +265,12 @@ export default {
         this.$emit("close");
       }
     },
-    handleScroll(event) {
-      const { scrollTop, scrollHeight, clientHeight } = event.target;
-      // 检查是否滚动到底部
-      if (scrollTop + clientHeight >= scrollHeight) {
-        // 滚动到最底部时的逻辑处理
-        console.log("已滚动到最底部");
-      }
-    },
-    scrollToBottom() {
-      this.$refs.scroll.scrollTop = this.$refs.scroll.scrollHeight;
+  },
+  watch: {
+    questionList() {
+      this.$nextTick(() => {
+        this.$refs.scrollRef.scrollTop = this.$refs.scrollRef.scrollHeight;
+      });
     },
   },
 };