From 9ad36122bbb009f9a55c1143b50d318851532c5a Mon Sep 17 00:00:00 2001
From: Tevin <tingquanren@163.com>
Date: Fri, 17 Nov 2023 12:04:42 +0800
Subject: [PATCH] 优化表单错误滚动

---
 forms/input/CInput.vue |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/forms/input/CInput.vue b/forms/input/CInput.vue
index ca251f7..5d01979 100644
--- a/forms/input/CInput.vue
+++ b/forms/input/CInput.vue
@@ -17,7 +17,7 @@
             :error="itemRes.error"
             :cursorSpacing="0"
             :value="value"
-            :onChange="evt => hanldeChange(evt)"
+            :onChange="evt => handleChange(evt)"
         >
             <slot v-if="!unit" />
             <text
@@ -54,16 +54,18 @@
     },
     computed: {
         value() {
-            return (this.itemRes.formData[this.itemRes.name] || '').replace(
+            return ((this.itemRes.formData[this.itemRes.name] || '') + '').replace(
                 /[\n\r]/g,
                 ''
             );
         },
     },
     methods: {
-        hanldeChange(evt) {
-            // 小程序中,可以粘贴换行符进来
-            const changeValue = (evt || '').replace(/[\n\r]/g, '');
+        handleChange(evt) {
+            // 去除首尾空格,小程序中还可以粘贴换行符进来
+            const changeValue = ((evt || '') + '')
+                .replace(/^\s+|\s+$/g, '')
+                .replace(/[\n\r\t]/g, '');
             this.itemRes.onChange(changeValue);
         },
     },

--
Gitblit v1.9.1