index.js 700 B

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