vue 数字滚动组件

js yekong 151℃

安装依赖

npm i vue-count-to --save

二次封装

<template>
  <countTo :startVal='startVal' :endVal='num' :duration='3000'></countTo>
</template>

<script>
import countTo from 'vue-count-to';

export default {
  name: "countTos",
  components: {countTo},
  props: {
    num: {
      type: Number,
      default() {
        return 0;
      }
    }
  },
  data() {
    return {
      startVal: 0,
    }
  },
  watch: {},
  mounted() {
  },
  methods: {}
}
</script>

<style lang="scss" scoped>

</style>

使用

<countTo :num="nums"></countTo>
import countTo from "@/countTo";
components: {countTo},
喜欢 (0)