mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
51 lines
973 B
Vue
51 lines
973 B
Vue
<template>
|
|
<span>
|
|
<no-ssr
|
|
placeholder="0"
|
|
tag="span"
|
|
>
|
|
<count-to
|
|
:start-val="lastEndVal || startVal"
|
|
:end-val="endVal"
|
|
:duration="duration"
|
|
:autoplay="autoplay"
|
|
:separator="separator"
|
|
/>
|
|
</no-ssr>
|
|
</span>
|
|
</template>
|
|
|
|
<script>
|
|
import CountTo from 'vue-count-to'
|
|
export default {
|
|
components: {
|
|
CountTo,
|
|
},
|
|
props: {
|
|
startVal: { type: Number, default: 0 },
|
|
endVal: { type: Number, required: true },
|
|
duration: { type: Number, default: 3000 },
|
|
autoplay: { type: Boolean, default: true },
|
|
separator: { type: String, default: '.' },
|
|
},
|
|
data() {
|
|
return {
|
|
lastEndVal: null,
|
|
isReady: false,
|
|
}
|
|
},
|
|
watch: {
|
|
endVal(endVal) {
|
|
if (this.isReady && this.startVal === 0 && !this.lastEndVal) {
|
|
this.lastEndVal = this.endVal
|
|
}
|
|
},
|
|
},
|
|
mounted() {
|
|
setTimeout(() => {
|
|
this.isReady = true
|
|
}, 500)
|
|
},
|
|
}
|
|
</script>
|