index.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. direction: {
  21. type: String,
  22. value: 'vertical',
  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. direction = _a.direction;
  37. child.setData({
  38. value: value.indexOf(child.data.name) !== -1,
  39. parentDisabled: disabled,
  40. direction: direction,
  41. });
  42. },
  43. },
  44. });