nrz cf9cfdb44b [new feature] 新增 Radio (#354)
* [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
2018-07-15 14:47:03 +08:00

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 })
}
}
});