index.js 940 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { VantComponent } from '../common/component';
  2. VantComponent({
  3. field: true,
  4. relation: {
  5. name: 'radio',
  6. type: 'descendant',
  7. linked: function linked(target) {
  8. var _this$data = this.data,
  9. value = _this$data.value,
  10. disabled = _this$data.disabled;
  11. target.set({
  12. value: value,
  13. disabled: disabled || target.data.disabled
  14. });
  15. }
  16. },
  17. props: {
  18. value: null,
  19. disabled: Boolean
  20. },
  21. watch: {
  22. value: function value(_value) {
  23. var children = this.getRelationNodes('../radio/index');
  24. children.forEach(function (child) {
  25. child.set({
  26. value: _value
  27. });
  28. });
  29. },
  30. disabled: function disabled(_disabled) {
  31. var children = this.getRelationNodes('../radio/index');
  32. children.forEach(function (child) {
  33. child.set({
  34. disabled: _disabled || child.data.disabled
  35. });
  36. });
  37. }
  38. }
  39. });