index.js 955 B

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