feat: migrate Checkbox/CheckboxGroup

This commit is contained in:
chenjiahan
2020-08-15 07:12:09 +08:00
parent 6f4c8f1e5b
commit cef8daf717
5 changed files with 32 additions and 26 deletions

View File

@@ -13,14 +13,16 @@ export default createComponent({
direction: String,
iconSize: [Number, String],
checkedColor: String,
value: {
modelValue: {
type: Array,
default: () => [],
},
},
emits: ['change', 'update:modelValue'],
watch: {
value(val) {
modelValue(val) {
this.$emit('change', val);
},
},
@@ -29,7 +31,7 @@ export default createComponent({
// @exposed-api
toggleAll(checked) {
if (checked === false) {
this.$emit('input', []);
this.$emit('update:modelValue', []);
return;
}
@@ -39,11 +41,11 @@ export default createComponent({
}
const names = children.map((item) => item.name);
this.$emit('input', names);
this.$emit('update:modelValue', names);
},
},
render() {
return <div class={bem([this.direction])}>{this.slots()}</div>;
return <div class={bem([this.direction])}>{this.$slots.default?.()}</div>;
},
});