index.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var relation_1 = require("../common/relation");
  4. var component_1 = require("../common/component");
  5. (0, component_1.VantComponent)({
  6. field: true,
  7. relation: (0, relation_1.useChildren)('checkbox', function (target) {
  8. this.updateChild(target);
  9. }),
  10. props: {
  11. max: Number,
  12. value: {
  13. type: Array,
  14. observer: 'updateChildren',
  15. },
  16. disabled: {
  17. type: Boolean,
  18. observer: 'updateChildren',
  19. },
  20. direction: {
  21. type: String,
  22. value: 'vertical',
  23. },
  24. },
  25. methods: {
  26. updateChildren: function () {
  27. var _this = this;
  28. this.children.forEach(function (child) { return _this.updateChild(child); });
  29. },
  30. updateChild: function (child) {
  31. var _a = this.data, value = _a.value, disabled = _a.disabled, direction = _a.direction;
  32. child.setData({
  33. value: value.indexOf(child.data.name) !== -1,
  34. parentDisabled: disabled,
  35. direction: direction,
  36. });
  37. },
  38. },
  39. });