提交 | 用户 | age
|
d98d05
|
1 |
import { VantComponent } from '../common/component'; |
53cc6f
|
2 |
import { useChildren } from '../common/relation'; |
d98d05
|
3 |
VantComponent({ |
S |
4 |
field: true, |
53cc6f
|
5 |
relation: useChildren('radio', function (target) { |
S |
6 |
this.updateChild(target); |
|
7 |
}), |
d98d05
|
8 |
props: { |
S |
9 |
value: { |
|
10 |
type: null, |
|
11 |
observer: 'updateChildren', |
|
12 |
}, |
53cc6f
|
13 |
direction: String, |
d98d05
|
14 |
disabled: { |
S |
15 |
type: Boolean, |
|
16 |
observer: 'updateChildren', |
|
17 |
}, |
|
18 |
}, |
|
19 |
methods: { |
|
20 |
updateChildren() { |
53cc6f
|
21 |
this.children.forEach((child) => this.updateChild(child)); |
d98d05
|
22 |
}, |
S |
23 |
updateChild(child) { |
53cc6f
|
24 |
const { value, disabled, direction } = this.data; |
d98d05
|
25 |
child.setData({ |
S |
26 |
value, |
53cc6f
|
27 |
direction, |
d98d05
|
28 |
disabled: disabled || child.data.disabled, |
S |
29 |
}); |
|
30 |
}, |
|
31 |
}, |
|
32 |
}); |