From a73e9984986427c88189f6dfa54fd84374fdf3ef Mon Sep 17 00:00:00 2001 From: Gary Fu Date: Sun, 31 Dec 2023 22:24:14 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A8=E5=8D=95=E7=89=B9=E6=AE=8A=E5=A4=84?= =?UTF-8?q?=E7=90=86checkbox=E5=92=8Cradio=E6=B2=A1=E6=9C=89value=E5=B1=9E?= =?UTF-8?q?=E6=80=A7=E7=9A=84=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common-form-control/control-child.vue | 19 ++++++++++++++++-- src/components/common-form-control/index.vue | 16 +++++++-------- src/components/common-table/index.vue | 4 ++-- src/views/tools/Forms.vue | 20 +++++++++++++++++++ 4 files changed, 47 insertions(+), 12 deletions(-) diff --git a/src/components/common-form-control/control-child.vue b/src/components/common-form-control/control-child.vue index 553c9e7..f1ba009 100644 --- a/src/components/common-form-control/control-child.vue +++ b/src/components/common-form-control/control-child.vue @@ -26,6 +26,19 @@ const label = computed(() => { } return option.label }) +/** + * element-plus的复选框和单选框没有value值,只有label用于存储值,因此特殊处理 + * @type {string[]} + */ +const labelAsValueKeys = ['checkbox', 'radio', 'checkbox-button', 'radio-button'] + +const labelOrValue = computed(() => { + const option = props.option + if (labelAsValueKeys.includes(option.type)) { + return option.value + } + return label.value +}) @@ -33,9 +46,11 @@ const label = computed(() => { + > + {{ label }} +