Skip to content

CountTo Number Animation ​

Number animation component.

Basic Usage ​

Set the endVal property to specify the final value. Set the startVal property to specify the starting value. Set the duration property to specify the time for number animation from start to end. Set the autoplay property to specify whether to play automatically. Set the decimals property to specify the number of decimal places to retain. Set the decimal property to specify the decimal point symbol. Set the prefix property to specify the number prefix. Set the suffix property to specify the number suffix. Set the fontSize property to specify the font size. Set the color property to specify the text color.

vue
<wd-count-to :endVal="2024" suffix="year" color="#16baaa"></wd-count-to>
<wd-count-to prefix="¥" :startVal="0" :decimals="2" :endVal="186.321" :fontSize="32" suffix="%" color="#1e9fff"></wd-count-to>
<wd-count-to prefix="¥" :startVal="0" :decimals="2" :endVal="21286.321" :fontSize="32" suffix="%" color="#ff5722"></wd-count-to>
<wd-count-to prefix="¥" :startVal="0" :decimals="2" :endVal="21286.321" :fontSize="32" suffix="%" color="#ffb800" :duration="2000"></wd-count-to>

Set Theme ​

Set the text theme through the type parameter. We provide five types: primary error success warning default.

html
<wd-count-to type="primary" prefix="¥" :startVal="0" :endVal="888888" suffix="%"></wd-count-to>
<wd-count-to type="error" prefix="¥" :startVal="0" :endVal="888888" suffix="%"></wd-count-to>
<wd-count-to type="success" prefix="¥" :startVal="0" :endVal="888888" suffix="%"></wd-count-to>
<wd-count-to type="warning" prefix="¥" :startVal="0" :endVal="888888" suffix="%"></wd-count-to>
<wd-count-to type="info" prefix="¥" :startVal="0" :endVal="888888" suffix="%"></wd-count-to>

Manual Control ​

Start the animation using the start method, pause it using the pause method, and reset it using the reset method.

html
<wd-count-to
  ref="countTo"
  :auto-start="false"
  prefix="¥"
  :startVal="1000"
  :decimals="3"
  :endVal="9999.32"
  :fontSize="32"
  suffix="%"
  color="#1e9fff"
></wd-count-to>
<wd-grid clickable border>
  <wd-grid-item text="Start" icon="play-circle-stroke" @itemclick="start" />
  <wd-grid-item text="Pause" icon="pause-circle" @itemclick="pause" />
  <wd-grid-item text="Reset" icon="refresh" @itemclick="reset" />
</wd-grid>
ts
import type { CountToInstance } from '@/uni_modules/wot-design-uni/components/wd-count-to/types'

const countTo = ref<CountToInstance>()

const start = () => {
  countTo.value!.start()
}
const pause = () => {
  countTo.value!.pause()
}
const reset = () => {
  countTo.value!.reset()
}

Attributes ​

ParameterDescriptionTypeOptionsDefaultVersion
fontSizeFont sizenumber16default1.3.8
colorText colorstring-''1.3.8
typeTheme typestring'primary' / 'error' / 'warning' / 'success'default1.3.9
startValStarting valuenumber-01.3.8
endValFinal valuenumber-20241.3.8
durationAnimation duration from start to endnumber-30001.3.8
autoplayAuto playboolean-true1.3.8
decimalsNumber of decimal places (must be >= 0)number-01.3.8
decimalDecimal point symbolstring-'.'1.3.8
separatorThousands separatorstring-','1.3.8
prefixPrefixstring--1.3.8
suffixSuffixstring--1.3.8
useEasingUse easing animationboolean-true1.3.8

Events ​

Event NameDescriptionParametersVersion
finishTriggered when animation completes—1.3.8
mountedTriggered when component is mounted-1.3.8

Methods ​

Method NameDescriptionParametersVersion
startStart animation—1.3.8
pausePause animation—1.3.8
resetReset animation, auto-starts if auto-start is true—1.3.8

Slots ​

NameDescriptionVersion
defaultDefault slot1.3.8
prefixPrefix slot1.3.8
suffixSuffix slot1.3.8

External Classes ​

Class NameDescriptionVersion
custom-classRoot node style1.3.8
custom-styleRoot node style1.3.8

Source Code ​

Documentation
• Component

Released under the MIT License.

Released under the MIT License.