index.vue 1.19 KB
<!--
 * @Date: 2022-08-30 13:46:51
 * @LastEditors: hookehuyr hookehuyr@gmail.com
 * @LastEditTime: 2023-03-29 15:07:12
 * @FilePath: /data-table/src/components/PickerField/index.vue
 * @Description: 单列选择器组件
-->
<template>
  <div v-if="HideShow" class="picker-field-page">
    <div class="label">
      <span v-if="item.component_props.required">&nbsp;*</span>
      {{ item.component_props.label }}
    </div>
    <van-field :name="item.name" :rules="item.rules" style="padding: 0;">
      <template #input>
        <my-component />
      </template>
    </van-field>
  </div>
</template>

<script setup>
import MyComponent from './MyComponent.vue';

const props = defineProps({
  item: Object,
});

// 注入子组件属性
provide('props', props.item);

// 隐藏显示
const HideShow = computed(() => {
  return !props.item.component_props.disabled
})

</script>

<style lang="less" scoped>
.picker-field-page {
  margin: 1rem;
  .label {
    // padding: 1rem 1rem 0 0;
    font-size: 0.9rem;
    font-weight: bold;

    span {
      color: red;
    }
  }
}

:deep(.van-cell--clickable) {
  border: 1px solid #eaeaea;
  border-radius: 0.25rem;
  padding: 0.25rem 0.5rem;
  margin-top: 0.5rem;
}
</style>