From c98acc813b9172b18768f6f063bd6dc5d45553cf Mon Sep 17 00:00:00 2001
From: Tevin <tingquanren@163.com>
Date: Mon, 10 Mar 2025 10:43:21 +0800
Subject: [PATCH] 输入框,修复小程序中光标位置总是跳到首位的问题

---
 plugins/qrcode/CQRCode.vue |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/plugins/qrcode/CQRCode.vue b/plugins/qrcode/CQRCode.vue
index 49a71aa..5658468 100644
--- a/plugins/qrcode/CQRCode.vue
+++ b/plugins/qrcode/CQRCode.vue
@@ -78,14 +78,14 @@
                         console.error(err);
                         return;
                     }
-                }
+                },
             );
         },
     },
     mounted() {
         if (process.env.TARO_ENV === 'h5') {
             const canvasBox = $(this.$refs.canvas.$el);
-            const finderTimer = setInterval(() => {
+            this.finderTimer = setInterval(() => {
                 const canvasDom = canvasBox.find('canvas');
                 if (canvasDom.length === 0) {
                     return;
@@ -95,10 +95,13 @@
                 }
                 this._renderQRCodeH5(canvasDom[0]);
                 this.lastContent = this.content;
-            }, 10);
+            }, 100);
         } else {
             // TODO: 小程序中获取canvas
         }
     },
+    beforeDestroy() {
+        clearInterval(this.finderTimer);
+    },
 };
 </script>
\ No newline at end of file

--
Gitblit v1.9.1