63041ac7dd47f261050de2acfa76b39fd611ab450503dec06432fa9aa381a5b112f6aa2ec684f198765ae1203964257691943c00f8a66e14fed958a247ecf8 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. # vue-countTo [![vue2](https://img.shields.io/badge/vue-2.x-brightgreen.svg)](https://vuejs.org/) [![Gemnasium](https://img.shields.io/gemnasium/mathiasbynens/he.svg)](https://github.com/PanJiaChen/vue-countTo) [![license](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/PanJiaChen/vue-countTo) [![npm](https://img.shields.io/npm/v/vue-count-to.svg)](https://www.npmjs.com/package/vue-count-to)
  2. vue-countTo is a dependency-free, lightweight vue component that can be overwrited easingFn by yourself.
  3. You can set startVal and endVal ,it will automatic judge count up or count down.
  4. It is support vue-ssr.
  5. It is learn from countUp.js;
  6. ## [Try the demo](http://panjiachen.github.io/countTo/demo/)
  7. ### How to use?
  8. ```bash
  9. npm install vue-count-to
  10. ```
  11. ### Example
  12. ```vue
  13. <template>
  14. <countTo :startVal='startVal' :endVal='endVal' :duration='3000'></countTo>
  15. </template>
  16. <script>
  17. import countTo from 'vue-count-to';
  18. export default {
  19. components: { countTo },
  20. data () {
  21. return {
  22. startVal: 0,
  23. endVal: 2017
  24. }
  25. }
  26. }
  27. </script>
  28. ```
  29. demo:
  30. ![demo](https://github.com/PanJiaChen/vue-countTo/blob/master/countDemo.gif)
  31. Use CDN Script: [demo](https://github.com/PanJiaChen/vue-countTo/blob/master/demo/index.html)
  32. ### Options
  33. | Property | Description | type | default |
  34. | ----------------- | ---------------- | :--------: | :----------: |
  35. | startVal | the value you want to begin at |Number| 0 |
  36. | endVal | the value you want to arrive at |Number | 2017 |
  37. | duration | duration in millisecond | Number | 3000 |
  38. | autoplay | when mounted autoplay | Boolean | true |
  39. | decimals | the number of decimal places to show | Number | 0 |
  40. | decimal | the split decimal | String | . |
  41. | separator | the separator | String | , |
  42. | prefix | the prefix | String | '' |
  43. | suffix | the suffix | String | '' |
  44. | useEasing | is use easing function | Boolean | true |
  45. | easingFn | the easing function | Function | — |
  46. ** notes: when autoplay:true , it will auto start when startVal or endVal change **
  47. ### Functions
  48. | Function Name | Description |
  49. | :--------: | ----- |
  50. | mountedCallback | when mounted will emit mountedCallback |
  51. | start | start the countTo |
  52. | pause | pause the countTo |
  53. | reset | reset the countTo |