Skip to content

Commit

Permalink
refactor(checkbox-group): optimize code
Browse files Browse the repository at this point in the history
  • Loading branch information
chouchouji committed May 21, 2024
1 parent f388f85 commit 96f0d14
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/varlet-ui/src/checkbox-group/CheckboxGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<checkbox-group-option
v-for="option in checkboxGroupOptions"
:key="option.value.toString()"
:checked-value="option.value"
:value="option.value"
:label="option.label"
:disabled="option.disabled"
:checked="modelValue.includes(option.value)"
Expand Down
6 changes: 3 additions & 3 deletions packages/varlet-ui/src/checkbox-group/CheckboxGroupOption.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ export default defineComponent({
name: 'CheckboxGroupOption',
props: {
label: [String, Function, Object] as PropType<string | VNode | CheckboxGroupLabelRender>,
checkedValue: [String, Number, Boolean, Object, Array] as PropType<any>,
value: [String, Number, Boolean, Object, Array] as PropType<any>,
disabled: Boolean,
checked: Boolean,
},
setup(props) {
return () => (
<Checkbox checkedValue={props.checkedValue} disabled={props.disabled}>
<Checkbox checkedValue={props.value} disabled={props.disabled}>
{isFunction(props.label)
? props.label({ label: props.label, disabled: props.disabled, value: props.checkedValue }, props.checked)
? props.label({ label: props.label, disabled: props.disabled, value: props.value }, props.checked)
: props.label}
</Checkbox>
)
Expand Down

0 comments on commit 96f0d14

Please sign in to comment.