1、安装vue-count-to
npm install vue-count-to --save
2、引入注册
import countTo from 'vue-count-to'
components: {
countTo
},
3、使用
<template>
<div>
<countTo :startVal="startVal" :endVal="endVal" :duration="2000"></countTo>
</div>
</template>
<script>
import countTo from 'vue-count-to'
export default {
components: {
countTo
},
data() {
return {
startVal: 0, //数字滚动的起点
endVal: 2021 //数字滚动的终点
}
},
}
</script>
<style scoped lang="scss">
</style>