index.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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: 'radio',
  8. type: 'descendant',
  9. linked: function (target) {
  10. this.children = this.children || [];
  11. this.children.push(target);
  12. this.updateChild(target);
  13. },
  14. unlinked: function (target) {
  15. this.children = this.children.filter(function (child) { return child !== target; });
  16. }
  17. },
  18. props: {
  19. value: {
  20. type: null,
  21. observer: 'updateChildren'
  22. },
  23. disabled: {
  24. type: Boolean,
  25. observer: 'updateChildren'
  26. }
  27. },
  28. methods: {
  29. updateChildren: function () {
  30. var _this = this;
  31. (this.children || []).forEach(function (child) {
  32. return _this.updateChild(child);
  33. });
  34. },
  35. updateChild: function (child) {
  36. var _a = this.data, value = _a.value, disabled = _a.disabled;
  37. child.set({
  38. value: value,
  39. disabled: disabled || child.data.disabled
  40. });
  41. }
  42. }
  43. });