index.js 961 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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,
  34. value = _a.value,
  35. disabled = _a.disabled;
  36. child.setData({
  37. value: value.indexOf(child.data.name) !== -1,
  38. parentDisabled: disabled,
  39. });
  40. },
  41. },
  42. });