index.js
1.15 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
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const component_1 = require("../common/component");
const relation_1 = require("../common/relation");
(0, component_1.VantComponent)({
field: true,
relation: (0, relation_1.useChildren)("checkbox", function (target) {
this.updateChild(target);
}),
props: {
max: Number,
value: {
type: Array,
observer: "updateChildren",
},
disabled: {
type: Boolean,
observer: "updateChildren",
},
direction: {
type: String,
value: "vertical",
},
},
methods: {
updateChildren () {
const _this = this;
this.children.forEach((child) => { return _this.updateChild(child); });
},
updateChild (child) {
const _a = this.data; const value = _a.value; const disabled = _a.disabled; const direction = _a.direction;
child.setData({
value: value.includes(child.data.name),
parentDisabled: disabled,
direction,
});
},
},
});