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