Feat: `Countup` display fixed value (#4266)

pull/4288/head
Nelson Chan 11 months ago committed by GitHub
parent c9fe6b5d01
commit d830fa4a0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,5 +1,5 @@
<template>
<span v-if="isNum" ref="output">{{ output }}</span> <span v-if="isNum">{{ unit }}</span>
<span v-if="isNum" ref="output">{{ outputFixed }}</span> <span v-if="isNum">{{ unit }}</span>
<span v-else>{{ value }}</span>
</template>
@ -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: {

Loading…
Cancel
Save