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