Skip to content

Commit

Permalink
fix(rate): 修复 rate 在开启文字显示与半星时,tooltip 显示异常的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
xixileng committed Jul 13, 2023
1 parent 104d151 commit 34f385e
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/rate/rate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ export default defineComponent({
const root = ref<HTMLTableElement>();

const displayValue = computed(() => Number(hoverValue.value || starValue.value));
const displayText = computed(() =>
const displayTexts = computed(() =>
props.texts.length === 0 ? ['极差', '失望', '一般', '满意', '惊喜'] : props.texts,
);
const displayText = computed(() => displayTexts.value[Math.ceil(displayValue.value - 1)]);

// 评分图标
const RateIcon = (iconProps: any) => {
Expand Down Expand Up @@ -90,7 +91,7 @@ export default defineComponent({
}}
>
{props.showText ? (
<Tooltip key={index} content={displayText.value[displayValue.value - 1]}>
<Tooltip key={index} content={displayText.value}>
<div class={`${classPrefix.value}-rate__star-top`}>
<RateIcon size={props.size} color={activeColor} />
</div>
Expand All @@ -111,9 +112,7 @@ export default defineComponent({
</li>
))}
</ul>
{props.showText && (
<div className={`${classPrefix.value}-rate__text`}>{displayText.value[displayValue.value - 1]}</div>
)}
{props.showText && <div className={`${classPrefix.value}-rate__text`}>{displayText.value}</div>}
</div>
);
};
Expand Down

0 comments on commit 34f385e

Please sign in to comment.