The countup @wines
@wines/countup用于展现计数器。
``xml
`
`ts
import './index.less';
import { CountUp } from '@wines/countup';
import { PageCustom, PageData } from '@wines/core';
Page
data: {},
onLoad() {
const setData = this.setData.bind(this);
this.c1 = new CountUp(1, 1024, 0, 2, {
printValue(value) {
setData({
c1: value,
});
},
});
this.c2 = new CountUp(0, 88.88, 2, 2, {
printValue(value) {
setData({
c2: value,
});
},
});
this.c3 = new CountUp(0, 520, 0, 2, {
printValue(value) {
setData({
c3: value,
});
},
});
this.c1.start();
this.c2.start();
},
start() {
this.c3.start(() => {
void wx.showToast({
title: '已完成',
});
});
},
reset() {
this.c3.reset();
},
update() {
this.c3.update(1314);
},
pauseResume() {
this.c3.pauseResume();
},
});
`
| 参数 | 类型 | 描述 | 默认值 |
| -------------------- | ---------- | ------------------ | ------ |
| startVal | number | 起始值 | - |number
| endVal | | 结束值 | - |number
| decimals | | 小数点位数 | 0 |number
| duration | | 刷新时间 | 0 |object
| options | | 配置项 | - |boolean
| options.useEasing | | 是否开启过渡动画 | true |boolean
| options.useGrouping | | 是否分隔数值 | true |string
| options.separator | | 分隔符 | , |string
| options.decimal | | 小数点符号 | . |function
| options.easingFn | | 自定义过渡动画 | - |function
| options.formattingFn | | 自定义格式化函数 | - |function` | 渲染组件的回调函数 | - |
| options.printValue |