Count Up 指数

使用指南

在 page.json 中引入组件

  1. "usingComponents": {
  2. "w-count-up": "wuss-weapp/w-count-up/index",
  3. }

视频演示

代码演示

  1. <w-pane title="CountUp" desc="指数" />
  2. <w-pane desc="Default" />
  3. <view
  4. style="color: #ff9900;padding: 15px 0;text-align: center;font-size: 40px;"
  5. hover-class="none"
  6. hover-stop-propagation="false"
  7. >
  8. {{ count }}
  9. </view>
  10. <view
  11. style="color: #ff9900;padding: 15px 0;text-align: center;font-size: 40px;"
  12. hover-class="none"
  13. hover-stop-propagation="false"
  14. >
  15. {{ count2 }}
  16. </view>
  17. <view
  18. style="color: #ff9900;padding: 15px 0;text-align: center;font-size: 40px;"
  19. hover-class="none"
  20. hover-stop-propagation="false"
  21. >
  22. {{ count3 }}
  23. </view>
  24. <w-form
  25. bind:submit="handleSubmit"
  26. >
  27. <w-cell-group>
  28. <w-input
  29. label="初始数字"
  30. name="startVal"
  31. value="0"
  32. />
  33. <w-input
  34. label="结束数字"
  35. name="endVal"
  36. value="3000"
  37. />
  38. <w-input
  39. label="保留小数点位数"
  40. name="decimals"
  41. value="2"
  42. />
  43. <w-input
  44. label="过渡时间"
  45. name="duration"
  46. value="3"
  47. />
  48. <w-button formType="submit" type="primary">
  49. 开始
  50. </w-button>
  51. </w-cell-group>
  52. </w-form>
  1. import {
  2. CountUp
  3. } from 'wuss-weapp/dist/index';
  4. data: {
  5. count: 0,
  6. count2: 0,
  7. count3: 0,
  8. },
  9. handleSubmit(e) {
  10. const { startVal = 0 , endVal = 3000, decimals = 0, duration = 3000 } = e.detail;
  11. this.setData({
  12. count: 0
  13. } , () => {
  14. new CountUp(startVal, endVal, decimals, duration, count => this.setData({
  15. count
  16. })).start()
  17. })
  18. },
  19. onShow: function () {
  20. new CountUp(0, 3000, 0, 3, count => this.setData({
  21. count
  22. })).start();
  23. new CountUp(1000, 2333.33, 2, 5, count2 => this.setData({
  24. count2
  25. })).start();
  26. new CountUp(666, 66666.6666, 4, 6, count3 => this.setData({
  27. count3
  28. })).start();
  29. },

API

Attribute 属性

属性说明类型默认值
startVal开始值number0
endVal结束值number0
decimals小数点位数number0
duration过渡时间number-
callback回调function-
options其他配置object-

, , , , ,

Event 事件

事件名说明参数

Slot 插槽

名称说明

Class 自定义类名

类名说明