index.vue 1.13 KB
<!--
 * @Date: 2022-08-30 11:34:19
 * @LastEditors: hookehuyr hookehuyr@gmail.com
 * @LastEditTime: 2022-11-21 15:15:51
 * @FilePath: /data-table/src/components/RadioField/index.vue
 * @Description: 单项选择控件
-->
<template>
  <div class="radio-field-page">
    <div class="label">
      {{ item.component_props.label
      }}<span v-if="item.component_props.required">&nbsp;*</span>
    </div>
    <van-field :name="item.key" :rules="item.rules">
      <template #input>
        <van-radio-group v-model="item.value" :direction="item.component_props.direction">
          <van-radio
            v-for="x in item.component_props.options"
            :key="index"
            :name="x"
            icon-size="1rem"
            style="margin-bottom: 0.25rem"
            >{{ x }}</van-radio
          >
        </van-radio-group>
      </template>
    </van-field>
  </div>
</template>

<script setup>
const props = defineProps({
  item: Object,
});
</script>

<style lang="less" scoped>
.radio-field-page {
  .label {
    padding: 1rem 1rem 0 1rem;
    font-size: 0.9rem;
    font-weight: bold;
    span {
      color: red;
    }
  }
}
</style>