<template>
  <el-radio-group :value="value" @input="updateVal($event)" v-bind="$attrs">
    <cms-radio :props="props" v-for="(item, index) in radioData[radioKey]" :row.sync="item" :key="index"></cms-radio>
  </el-radio-group>
</template>

<script>
export default {
  inheritAttrs: false,
  name: "CmsRadioGroup",
  props: {
    radioData: {
      type: Object,
      required: true,
      default: () => {
        return {}
      }
    },
    radioKey: {
      type: String,
      required: true,
      default: () => {
        return undefined
      }
    },
    // //此处一定要用value
    value: {
      type: [String, Number, Boolean, Array],
      default: () => {
        return ''
      }
    },
    props: {
      type: Object,
      default: () => {
        return {label: 'label', value: 'value'}
      }
    }
  },
  methods: {
    updateVal(val) {
      this.$emit('input', val); // 通过事件实现组件属性到父组件的传递
    },
  }
}
</script>

<style scoped>

</style>
