<!-- Created by Zoiew|zhiwei on 20/11/01. -->
<template>
  <div>
    <dof-radio-item
      v-for="(item, i) in list"
      :key="i"
      :config="config"
      v-bind="item"
      @dofRadioItemChecked="dofRadioItemChecked(i, $event)"
    ></dof-radio-item>
  </div>
</template>

<style scoped></style>

<script>
import DofRadioItem from './item.vue'

export default {
  components: { DofRadioItem },
  props: {
    list: {
      type: Array,
      default: () => []
    },
    config: {
      type: Object,
      default: () => ({})
    }
  },
  data: () => ({
    checkedIndex: -1
  }),
  computed: {},

  created() {},
  methods: {
    dofRadioItemChecked(i, e) {
      const { list } = this
      list &&
        list.forEach((item, index) => {
          this.$set(item, 'checked', index === i)
        })
      let checkedItem = list[i]
      this.$emit('dofRadioItemChecked', { ...checkedItem })
    }
  }
}
</script>
