liyongli 2 年之前
父節點
當前提交
d0a048fd85
共有 1 個文件被更改,包括 6 次插入8 次删除
  1. 6 8
      src/view/chatGptChatNew/index.vue

+ 6 - 8
src/view/chatGptChatNew/index.vue

@@ -1,5 +1,5 @@
 <template>
-  <div :class="{ chatGptChat: true, ortherP: !userData.UserId }" ref="chatEle" >
+  <div :class="{ chatGptChat: true, ortherP: !userData.UserId }" ref="chatEle">
     <div v-for="(item, index) in chat" :key="index">
       <div v-if="item.text && item.type === 'robot'" class="chat">
         <van-image width="35px" height="35px" fit="contain" :src="robot" />
@@ -134,13 +134,11 @@ function saveText() {
     });
 }
 function focus() {
-  let t = window.setTimeout(() => {
-    window.clearTimeout(t);
-    if (chatEle.value.scrollHeight > chatEle.value.clientHeight) {
-      chatEle.value.scrollTop = chatEle.value.scrollHeight;
-    }
-    document.getElementById("van-field-6-input") && document.getElementById("van-field-6-input").scrollIntoView();
-  }, 1000);
+  if (chatEle.value.scrollHeight > chatEle.value.clientHeight) {
+    chatEle.value.scrollTop = chatEle.value.scrollHeight;
+  }
+  document.getElementById('van-field-6-input') &&
+    document.getElementById('van-field-6-input').scrollIntoView();
 }
 </script>
 <style lang="scss">