From 8cd15fe62691a0b03853b0124e8bec233012aa8b Mon Sep 17 00:00:00 2001 From: Tevin <tingquanren@163.com> Date: Thu, 04 Jan 2024 15:03:25 +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 d23c616..211d760 100644 --- a/forms/input/CInput.vue +++ b/forms/input/CInput.vue @@ -6,7 +6,7 @@ <template> <view class="c-input" - :class="[unit?'c-input-unit':'', readOnly ? 'read-only':'']" + :class="[unit?'c-input-unit':'', readOnly?'read-only':'']" > <AtInput :name="itemRes.name" @@ -17,7 +17,7 @@ :error="itemRes.error" :cursorSpacing="0" :value="value" - :onChange="evt => hanldeChange(evt)" + :onChange="evt => handleChange(evt)" > <slot v-if="!unit" /> <text @@ -61,9 +61,11 @@ }, }, 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