From c709bfabfbddc48b2392c287aede1138cb3599c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=B1=9F=E8=BE=B0?= Date: Fri, 1 Dec 2023 11:05:47 +0800 Subject: [PATCH] fix(statistic): fix with missing default precision in animation (#3650) --- src/statistic/statistic.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/statistic/statistic.tsx b/src/statistic/statistic.tsx index f6ab0914b9..97ad152a1d 100644 --- a/src/statistic/statistic.tsx +++ b/src/statistic/statistic.tsx @@ -31,6 +31,9 @@ export default defineComponent({ }; const numberValue = computed(() => (isNumber(props.value) ? props.value : 0)); const innerValue = ref(props.animation?.valueFrom ?? props.value); + const innerDecimalPlaces = computed( + () => props.decimalPlaces ?? numberValue.value.toString().split('.')[1]?.length ?? 0, + ); const tween = ref(); const { value } = toRefs(props); @@ -46,7 +49,7 @@ export default defineComponent({ }, duration: props.animation.duration, onUpdate: (keys) => { - innerValue.value = keys.value; + innerValue.value = Number(keys.value.toFixed(innerDecimalPlaces.value)); }, onFinish: () => { innerValue.value = to;