index.js 1.1 KB

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