mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-09-10 12:56:13 +08:00
Feat: Countup
display fixed value (#4266)
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<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>
|
<span v-else>{{ value }}</span>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -37,6 +37,19 @@ export default {
|
|||||||
isNum() {
|
isNum() {
|
||||||
return typeof this.value === "number";
|
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: {
|
watch: {
|
||||||
|
Reference in New Issue
Block a user