feat: migrate Radio/RadioGroup

This commit is contained in:
chenjiahan
2020-08-15 07:20:25 +08:00
parent ab067ecb0c
commit 2172cce8b6
5 changed files with 20 additions and 12 deletions

View File

@@ -8,13 +8,15 @@ export default createComponent({
mixins: [ParentMixin('vanRadio'), FieldMixin],
props: {
value: null,
disabled: Boolean,
direction: String,
modelValue: null,
checkedColor: String,
iconSize: [Number, String],
},
emits: ['change', 'update:modelValue'],
watch: {
value(value) {
this.$emit('change', value);
@@ -24,7 +26,7 @@ export default createComponent({
render() {
return (
<div class={bem([this.direction])} role="radiogroup">
{this.slots()}
{this.$slots.default?.()}
</div>
);
},

View File

@@ -12,14 +12,16 @@ export default createComponent({
}),
],
emits: ['click', 'update:modelValue'],
computed: {
currentValue: {
get() {
return this.parent ? this.parent.value : this.value;
return this.parent ? this.parent.modelValue : this.modelValue;
},
set(val) {
(this.parent || this).$emit('input', val);
(this.parent || this).$emit('update:modelValue', val);
},
},