From 7cb91d0efcbff3297de5d8f64948033d13a86142 Mon Sep 17 00:00:00 2001
From: Tevin <tingquanren@163.com>
Date: Tue, 12 Apr 2022 17:58:03 +0800
Subject: [PATCH] 公共方法,增加网络检测

---
 forms/input/CInput.vue |   20 ++++++++++++++++++--
 1 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/forms/input/CInput.vue b/forms/input/CInput.vue
index 171f765..74d986e 100644
--- a/forms/input/CInput.vue
+++ b/forms/input/CInput.vue
@@ -15,8 +15,9 @@
             :placeholder="placeholder"
             :required="itemRes.required"
             :error="itemRes.error"
-            :value="itemRes.formData[itemRes.name]"
-            :onChange="evt=>itemRes.onChange(evt)"
+            :cursorSpacing="0"
+            :value="value"
+            :onChange="evt => hanldeChange(evt)"
         >
             <slot v-if="!unit" />
             <text
@@ -46,6 +47,21 @@
         // 输入框单位
         unit: String,
     },
+    computed: {
+        value() {
+            return (this.itemRes.formData[this.itemRes.name] || '').replace(
+                /[\n\r]/g,
+                ''
+            );
+        },
+    },
+    methods: {
+        hanldeChange(evt) {
+            // 小程序中,可以粘贴换行符进来
+            const changeValue = (evt || '').replace(/[\n\r]/g, '');
+            this.itemRes.onChange(changeValue);
+        },
+    },
     mounted() {},
 };
 </script>
\ No newline at end of file

--
Gitblit v1.9.1