Skip to content

Commit

Permalink
fix(radio-group): disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
catiwang committed Mar 14, 2024
1 parent 28d14b7 commit 02bfb92
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/radio-group/radio-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ export default class RadioGroup extends SuperComponent {
options() {
this.initWithOptions();
},
disabled(v) {
this.getChildren().forEach((item) => {
item.setDisabled(v);
});
},
};

methods = {
Expand All @@ -73,7 +78,7 @@ export default class RadioGroup extends SuperComponent {

// 支持自定义options
initWithOptions() {
const { options, value, keys } = this.data;
const { options, value, keys, disabled } = this.data;
// 数字数组|字符串数组|对像数组
if (!options?.length || !Array.isArray(options)) {
this.setData({
Expand All @@ -90,13 +95,15 @@ export default class RadioGroup extends SuperComponent {
label: `${element}`,
value: element,
checked: value === element,
disabled,
});
} else if (typeName === 'object') {
optionsValue.push({
...element,
label: element[keys?.label ?? 'label'],
value: element[keys?.value ?? 'value'],
checked: value === element[keys?.value ?? 'value'],
disabled: element.disabled || disabled,
});
}
});
Expand Down

0 comments on commit 02bfb92

Please sign in to comment.