From 8e50f43946586ec9c6136773b0e104fbfe79b952 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=87=E5=A4=A9?= Date: Thu, 15 Apr 2021 18:47:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8D=95=E9=80=89/=E5=A4=8D?= =?UTF-8?q?=E9=80=89=E7=9A=84=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/form/checkbox-item.wc | 2 +- src/form/checkbox.wc | 10 +++++----- src/form/radio-item.wc | 2 +- src/form/radio.wc | 12 +++++++----- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/form/checkbox-item.wc b/src/form/checkbox-item.wc index 9e62865..8ea670e 100644 --- a/src/form/checkbox-item.wc +++ b/src/form/checkbox-item.wc @@ -283,7 +283,7 @@ export default class Checkbox { if (k === 'readonly') { k = 'readOnly' } - this[k] = true + this[k] = val !== null break } } diff --git a/src/form/checkbox.wc b/src/form/checkbox.wc index 0ef29c9..b65731b 100644 --- a/src/form/checkbox.wc +++ b/src/form/checkbox.wc @@ -117,13 +117,13 @@ export default class CheckboxGroup { case 'readonly': case 'disabled': + var k = name + if (k === 'readonly') { + k = 'readOnly' + } Array.from(this.children).forEach(it => { if (it.tagName === 'WC-CHECKBOX' && it.root) { - if (val === null) { - it.removeAttribute(name) - } else { - it.setAttribute(name, '') - } + it[k] = val !== null } }) break diff --git a/src/form/radio-item.wc b/src/form/radio-item.wc index 1e871a5..0f20494 100644 --- a/src/form/radio-item.wc +++ b/src/form/radio-item.wc @@ -269,7 +269,7 @@ export default class Radio { if (k === 'readonly') { k = 'readOnly' } - this[k] = true + this[k] = val !== null break } } diff --git a/src/form/radio.wc b/src/form/radio.wc index 6631041..4efc2a7 100644 --- a/src/form/radio.wc +++ b/src/form/radio.wc @@ -104,13 +104,15 @@ export default class RadioGroup { case 'readonly': case 'disabled': + var k = name + if (k === 'readonly') { + k = 'readOnly' + } + console.log('变了', k, val, typeof val) Array.from(this.children).forEach(it => { if (it.tagName === 'WC-RADIO' && it.root) { - if (val === null) { - it.removeAttribute(name) - } else { - it.setAttribute(name, '') - } + it[k] = val !== null + console.log('-----', k, it[k], val !== null, '-----') } }) break