<template>
  <div>
    <van-radio-group @change="change" v-model="checked" direction="horizontal">
      <van-radio
        :name="v.attr.name"
        v-for="(v, i) in item.child_list"
        :key="'radio' + i"
        checked-color="#ff2c2c"
        >{{ v.attr.name }}</van-radio
      >
    </van-radio-group>
  </div>
</template>

<script setup>
import { defineProps, ref, defineEmits } from 'vue';
const props = defineProps({
  item: {
    type: Object,
  },
});
const emit = defineEmits(['setKey']);
const checked = ref(props.item.child_list[0].attr.name);
emit('setKey', { value: props.item.child_list[0].attr.name, key: props.item.key });
const change = () => {
  emit('setKey', { value: checked.value, key: props.item.key });
};
</script>
