index.js 734 B

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