chore(Checkbox): remove checked setter

This commit is contained in:
chenjiahan 2020-10-06 16:46:08 +08:00
parent 9e9f0e3d4d
commit 9aabb42f9d
2 changed files with 10 additions and 16 deletions

View File

@ -46,24 +46,19 @@ export default createComponent({
} }
}; };
const checked = computed({ const checked = computed(() => {
get() {
if (parent) { if (parent) {
return parent.props.modelValue.indexOf(props.name) !== -1; return parent.props.modelValue.indexOf(props.name) !== -1;
} }
return props.modelValue; return props.modelValue;
},
set(value) {
if (parent) {
setParentValue(value);
} else {
emit('update:modelValue', value);
}
},
}); });
const toggle = (newValue = !checked.value) => { const toggle = (newValue = !checked.value) => {
checked.value = newValue; if (parent) {
setParentValue(newValue);
} else {
emit('update:modelValue', newValue);
}
}; };
watch( watch(

View File

@ -157,7 +157,6 @@ export default createComponent({
if (slots.default) { if (slots.default) {
return slots.default(); return slots.default();
} }
if (props.text) { if (props.text) {
return <div class={bem('text')}>{props.text}</div>; return <div class={bem('text')}>{props.text}</div>;
} }