You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
759 B
32 lines
759 B
4 years ago
|
import { createNamespace } from '../utils';
|
||
|
import { CheckboxMixin } from '../mixins/checkbox';
|
||
|
|
||
|
var _createNamespace = createNamespace('radio'),
|
||
|
createComponent = _createNamespace[0],
|
||
|
bem = _createNamespace[1];
|
||
|
|
||
|
export default createComponent({
|
||
|
mixins: [CheckboxMixin({
|
||
|
bem: bem,
|
||
|
role: 'radio',
|
||
|
parent: 'vanRadio'
|
||
|
})],
|
||
|
computed: {
|
||
|
currentValue: {
|
||
|
get: function get() {
|
||
|
return this.parent ? this.parent.value : this.value;
|
||
|
},
|
||
|
set: function set(val) {
|
||
|
(this.parent || this).$emit('input', val);
|
||
|
}
|
||
|
},
|
||
|
checked: function checked() {
|
||
|
return this.currentValue === this.name;
|
||
|
}
|
||
|
},
|
||
|
methods: {
|
||
|
toggle: function toggle() {
|
||
|
this.currentValue = this.name;
|
||
|
}
|
||
|
}
|
||
|
});
|