mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-06 03:58:05 +08:00
* [new component]: Radio * [new component]: Radio misc * [new component] Radio code review * [new component] Radio code review * [new component] Radio misc * [new component] Radio improve style
32 lines
542 B
JavaScript
32 lines
542 B
JavaScript
Component({
|
|
behaviors: ['wx://form-field'],
|
|
|
|
externalClasses: ['radio-class', 'radio-color'],
|
|
|
|
properties: {
|
|
items: Array,
|
|
type: String
|
|
},
|
|
|
|
methods: {
|
|
radioChange(e) {
|
|
this.selectItem(e.detail.value)
|
|
this.triggerEvent('change', e)
|
|
},
|
|
|
|
selectItem(value) {
|
|
let { items } = this.data;
|
|
|
|
items.forEach(item => {
|
|
if ( item.name === value ) {
|
|
item.checked = true;
|
|
} else {
|
|
item.checked = false;
|
|
}
|
|
})
|
|
|
|
this.setData({ items })
|
|
}
|
|
}
|
|
});
|