MyComponent.vue
918 Bytes
<!--
* @Date: 2023-03-29 13:09:02
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2023-03-29 13:22:01
* @FilePath: /data-table/src/components/RatePickerField/MyComponent.vue
* @Description: 文件描述
-->
<template>
<div style="width: 100%;">
<van-rate
v-model="rate_value"
:count="props.component_props.data_length"
:readonly="props.component_props.readonly"
:color="styleColor.baseColor"
style="padding: 1rem"
/>
<van-divider />
</div>
</template>
<script setup>
import { ref } from 'vue'
import { useCustomFieldValue } from '@vant/use';
import { styleColor } from "@/constant.js";
// 获取父组件传值
const props = inject('props');
const rate_value = ref(props.component_props.default);
// 此处传入的值会替代 Field 组件内部的 value
useCustomFieldValue(() => rate_value.value);
</script>
<style lang="less" scoped>
</style>