From 81a735caa69952bc24e0fa3e08549974dc11ff21 Mon Sep 17 00:00:00 2001 From: Tevin <tingquanren@163.com> Date: Mon, 18 Mar 2024 20:02:36 +0800 Subject: [PATCH] 修复签名组件,小程序中,上传图片报错的问题 --- forms/input/CInput.vue | 14 ++++++++------ 1 files changed, 8 insertions(+), 6 deletions(-) diff --git a/forms/input/CInput.vue b/forms/input/CInput.vue index ca251f7..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 @@ -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