index.js 903 B

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