index.js 937 B

1234567891011121314151617181920212223242526272829303132333435363738
  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. component_1.VantComponent({
  6. field: true,
  7. relation: 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. },
  21. methods: {
  22. updateChildren: function () {
  23. var _this = this;
  24. this.children.forEach(function (child) {
  25. return _this.updateChild(child);
  26. });
  27. },
  28. updateChild: function (child) {
  29. var _a = this.data,
  30. value = _a.value,
  31. disabled = _a.disabled;
  32. child.setData({
  33. value: value.indexOf(child.data.name) !== -1,
  34. parentDisabled: disabled,
  35. });
  36. },
  37. },
  38. });