From d830fa4a0e2d3a98617d94daad725419f2112fd8 Mon Sep 17 00:00:00 2001 From: Nelson Chan <3271800+chakflying@users.noreply.github.com> Date: Thu, 21 Dec 2023 20:09:59 +0800 Subject: [PATCH] Feat: `Countup` display fixed value (#4266) --- src/components/CountUp.vue | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/components/CountUp.vue b/src/components/CountUp.vue index 9ce68507..3bd01075 100644 --- a/src/components/CountUp.vue +++ b/src/components/CountUp.vue @@ -1,5 +1,5 @@ @@ -37,6 +37,19 @@ export default { isNum() { return typeof this.value === "number"; }, + outputFixed() { + if (typeof this.output === "number") { + if (this.output < 1) { + return "<1"; + } else if (Number.isInteger(this.output)) { + return this.output; + } else { + return this.output.toFixed(2); + } + } else { + return this.output; + } + } }, watch: {