From 3ba750db9edc86d49a5885a4eb2ecbe117733974 Mon Sep 17 00:00:00 2001 From: wangchen Date: Fri, 19 Jan 2024 15:30:39 +0800 Subject: [PATCH] fix(rate): fix not display in nuxt --- packages/web-vue/components/rate/rate.tsx | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/packages/web-vue/components/rate/rate.tsx b/packages/web-vue/components/rate/rate.tsx index 635fe7f57..c5bc89036 100644 --- a/packages/web-vue/components/rate/rate.tsx +++ b/packages/web-vue/components/rate/rate.tsx @@ -229,12 +229,18 @@ export default defineComponent({ }; }; + const renderElement = (index: number) => { + if (props.grading) { + return renderGradingCharacter(index, displayIndex.value); + } + if (slots.character) { + return slots.character({ index }); + } + return ; + }; + // TODO: need to perf const renderCharacter = (index: number) => { - const displayCharacter = props.grading - ? renderGradingCharacter(index, displayIndex.value) - : slots.character?.({ index }) ?? ; - const leftProps = mergedDisabled.value ? {} : { @@ -289,7 +295,7 @@ export default defineComponent({ {...leftProps} {...(props.allowHalf ? getAriaProps(index, true) : undefined)} > - {displayCharacter} + {renderElement(index)}
- {displayCharacter} + {renderElement(index)}
);