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

@ -49,4 +49,6 @@ module.exports = [
'calendar', 'calendar',
'checkbox', 'checkbox',
'checkbox-group', 'checkbox-group',
'radio',
'radio-group',
]; ];

View File

@ -37,6 +37,8 @@ Vant 遵循 [Semver](https://semver.org/lang/zh-CN/) 语义化版本规范。
- Checkbox - Checkbox
- CheckboxGroup - CheckboxGroup
- Field - Field
- Radio
- RadioGroup
- Switch - Switch
- Sidebar - Sidebar

View File

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

View File

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

View File

@ -147,10 +147,10 @@ module.exports = {
path: 'picker', path: 'picker',
title: 'Picker 选择器', title: 'Picker 选择器',
}, },
// { {
// path: 'radio', path: 'radio',
// title: 'Radio 单选框', title: 'Radio 单选框',
// }, },
{ {
path: 'rate', path: 'rate',
title: 'Rate 评分', title: 'Rate 评分',
@ -481,10 +481,10 @@ module.exports = {
path: 'picker', path: 'picker',
title: 'Picker', title: 'Picker',
}, },
// { {
// path: 'radio', path: 'radio',
// title: 'Radio', title: 'Radio',
// }, },
{ {
path: 'rate', path: 'rate',
title: 'Rate', title: 'Rate',