From a26ac3e9f4d753d3eb7a0ac061b81f9db39dce4f Mon Sep 17 00:00:00 2001 From: tangjinzhou <415800467@qq.com> Date: Thu, 11 Aug 2022 14:24:39 +0800 Subject: [PATCH] feat: rating character add params --- components/rate/Star.tsx | 20 ++++++++++++++------ components/rate/index.tsx | 4 ++-- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/components/rate/Star.tsx b/components/rate/Star.tsx index 76e0043b4..2112df096 100644 --- a/components/rate/Star.tsx +++ b/components/rate/Star.tsx @@ -1,6 +1,5 @@ import type { ExtractPropTypes } from 'vue'; import { defineComponent, computed } from 'vue'; -import { getPropsSlot } from '../_util/props-util'; import PropTypes from '../_util/vue-types'; export const starProps = { @@ -24,7 +23,7 @@ export default defineComponent({ inheritAttrs: false, props: starProps, emits: ['hover', 'click'], - setup(props, { slots, emit }) { + setup(props, { emit }) { const onHover = (e: MouseEvent) => { const { index } = props; emit('hover', e, index); @@ -61,8 +60,17 @@ export default defineComponent({ }); return () => { - const { disabled, prefixCls, characterRender, index, count, value } = props; - const character = getPropsSlot(slots, props, 'character'); + const { disabled, prefixCls, characterRender, character, index, count, value } = props; + const characterNode = + typeof character === 'function' + ? character({ + disabled, + prefixCls, + index, + count, + value, + }) + : character; let star = (