liyongli 2 年之前
父节点
当前提交
c80e041dbd
共有 2 个文件被更改,包括 9 次插入1 次删除
  1. 1 0
      src/view/chatGptChat/index.js
  2. 8 1
      src/view/chatGptChat/index.vue

+ 1 - 0
src/view/chatGptChat/index.js

@@ -27,3 +27,4 @@ window.setUserSession = () => {
   console.log('登录');
   getUser(() => createApp(App).mount('#app'));
 };
+

+ 8 - 1
src/view/chatGptChat/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" />
@@ -29,6 +29,7 @@
       autosize
       placeholder="请输入您的问题"
       type="textarea"
+      @focus="focus"
     >
       <template #button>
         <van-button
@@ -129,6 +130,12 @@ function saveText() {
       load.value = false;
     });
 }
+function focus(){
+    let t = setTimeout(() => {
+        document.getElementById("van-field-6-input") && document.getElementById("van-field-6-input").scrollIntoView();
+        window.clearTimeout(t);
+    }, 200);
+}
 </script>
 <style lang="scss">
 .chatGptChat {