duanshenglang 4 месяцев назад
Родитель
Сommit
d528f2fe97
1 измененных файлов с 17 добавлено и 9 удалено
  1. 17 9
      lottery/smartTab.html

+ 17 - 9
lottery/smartTab.html

@@ -395,6 +395,8 @@
         },
         transformedData: [],
         areaData: [],
+        titleTimer: null,
+        titleOutput: false
       }
     },
     created() {
@@ -625,16 +627,22 @@
           this.loading = false
         })
       },
-      titleWriter (str) {
-        let that = this
-        let i = 0;
-        let timer = setInterval(function () {
-          that.replyData.reply += str.charAt(i)
-          i++;
-          if (i >= str.length) {
-            clearInterval(timer);
+      titleWriter (text) {
+        clearTimeout(this.titleTimer)
+        this.titleTimer = null
+        let index = 0
+        this.replyData.reply = ''
+        this.titleOutput = true
+        const writeText = () => {
+          if (index < text.length) {
+            this.replyData.reply += text.charAt(index)
+            index++
+            this.titleTimer = setTimeout(writeText, 50)
+          } else {
+            this.titleOutput = false
           }
-        }, 50);
+        }
+        writeText()
       },
       // 客户洞察
       insight () {