1.npm安装
npm install vue-count-to --save
2.使用
<template>
<countTo :startVal='startVal' :endVal='endVal' :duration='duration'></countTo>
</template>
<script>
import countTo from 'vue-count-to';
export default {
components: { countTo },
data () {
return {
// 需要滚动的时间
duration: 5000,
// 初始值
startVal: 0,
// 最终值
endVal: 2018
}
}
}
</script>