index.js
1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { VantComponent } from '../common/component';
VantComponent({
field: true,
relation: {
name: 'radio-group',
type: 'ancestor'
},
classes: ['icon-class', 'label-class'],
props: {
name: null,
value: null,
disabled: Boolean,
labelDisabled: Boolean,
labelPosition: String
},
computed: {
iconClass: function iconClass() {
var _this$data = this.data,
disabled = _this$data.disabled,
name = _this$data.name,
value = _this$data.value;
return this.classNames('van-radio__icon', {
'van-radio__icon--disabled': disabled,
'van-radio__icon--checked': !disabled && name === value,
'van-radio__icon--check': !disabled && name !== value
});
}
},
methods: {
emitChange: function emitChange(value) {
var instance = this.getRelationNodes('../radio-group/index')[0] || this;
instance.$emit('input', value);
instance.$emit('change', value);
},
onChange: function onChange(event) {
this.emitChange(event.detail.value);
},
onClickLabel: function onClickLabel() {
if (!this.data.disabled && !this.data.labelDisabled) {
this.emitChange(this.data.name);
}
}
}
});