CustomerTypeRadio.vue 1.04 KB
<template>
  <radio-group @change="handleChange" class="radio-group">
    <template v-for="(item, index) in items">
      <label class="radio" :key="index">
        <radio :value="item.value" :checked="value == item.value" />
        {{ item.label }}
      </label>
    </template>
  </radio-group>
</template>

<script>
export default {
  name: "CustomerTypeRadio",
  props: {
    value: {
      type: [String, Number],
      default: ''
    },
    items: {
      type: Array,
      default: () => [
        {
          label: "VIP",
          value: 'VIP'
        },
        {
          label: "潜客",
          value: '潜客'
        },
        {
          label: "普通",
          value: '普通'
        }
      ]
    }
  },
  methods: {
    handleChange(e) {
      this.$emit('input', e.detail.value);
      this.$emit('change', e);
    }
  }
}
</script>

<style scoped lang="scss">
.radio-group {
  display: flex;
  align-items: center;
  height: 100%;

  .radio {
    display: flex;
    align-items: center;
    margin-right: toRpx(30);
  }
}
</style>