From a5355c38114640c5e54863ba14a1de6485ed38c0 Mon Sep 17 00:00:00 2001 From: Tevin <tingquanren@163.com> Date: Mon, 05 Jun 2023 20:36:22 +0800 Subject: [PATCH] Merge branch 'master' of ssh://dev.zhiheiot.com:29418/mob-components --- forms/input/CInput.vue | 15 +++++++++++---- 1 files changed, 11 insertions(+), 4 deletions(-) diff --git a/forms/input/CInput.vue b/forms/input/CInput.vue index 74d986e..7c8d604 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':''" + :class="[unit?'c-input-unit':'', readOnly ? 'read-only':'']" > <AtInput :name="itemRes.name" @@ -46,10 +46,15 @@ placeholder: String, // 输入框单位 unit: String, + // 只读模式 + readOnly: { + type: Boolean, + default: false, + }, }, computed: { value() { - return (this.itemRes.formData[this.itemRes.name] || '').replace( + return ((this.itemRes.formData[this.itemRes.name] || '') + '').replace( /[\n\r]/g, '' ); @@ -57,8 +62,10 @@ }, methods: { hanldeChange(evt) { - // 小程序中,可以粘贴换行符进来 - const changeValue = (evt || '').replace(/[\n\r]/g, ''); + // 去除首尾空格,小程序中还可以粘贴换行符进来 + const changeValue = ((evt || '') + '') + .replace(/^\s+|\s+$/g, '') + .replace(/[\n\r\t]/g, ''); this.itemRes.onChange(changeValue); }, }, -- Gitblit v1.9.1