index.vue 1005 Bytes
<!--
 * @Date: 2022-08-30 11:34:19
 * @LastEditors: hookehuyr hookehuyr@gmail.com
 * @LastEditTime: 2022-09-07 16:06:06
 * @FilePath: /data-table/src/components/CheckboxField/index.vue
 * @Description: 文件描述
-->
<template>
  <div class="checkbox-field-page">
    <div class="label">{{ item.label }}<span v-if="item.required">&nbsp;*</span></div>
    <van-field :name="item.key" :border="false">
      <template #input>
        <van-checkbox-group v-model="item.value">
          <van-checkbox v-for="x in item.options" :key="index" :name="x.key" icon-size="1rem" shape="square"
            style="margin-bottom: 0.25rem;">{{ x.value }}</van-checkbox>
        </van-checkbox-group>
      </template>
    </van-field>
  </div>
</template>

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

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