Skip to content

witCount Number Counter

witCount is a number animation counter component, used to achieve smooth transition animation effects from start value to end value. The component supports custom animation duration, decimal places, number format, prefix, suffix and other configurations, suitable for data display, statistics, countdown and other scenarios.

Usage Example

vue
<template>
  <div>
    <!-- Basic usage -->
    <witCount
      :start-value="0"
      :end-value="1000"
      :duration="2000"
    />
    
    <!-- Number with formatting -->
    <witCount
      :start-value="0"
      :end-value="12345.678"
      :duration="3000"
      :decimals="2"
      separator=","
      prefix="$"
      suffix=" USD"
    />
    
    <!-- Custom easing function -->
    <witCount
      :start-value="0"
      :end-value="500"
      :duration="1500"
      :use-easing="true"
      :easing-fn="[0.5, 0.2, 0.3, 1]"
    />
  </div>
</template>

<script lang="ts" setup>
// No additional import needed, component is globally registered
</script>

API

Component

Component NameDescription
witCountNumber counter main component

Properties

Property NameTypeDefault ValueDescription
startValueNumber0Animation start value
endValueNumber20Animation end value
durationNumber3000Animation duration (milliseconds)
autoplayBooleantrueWhether to auto start animation
decimalsNumber0Decimal places
decimalString.Decimal point symbol
separatorString,Thousand separator
prefixString''Number prefix
suffixString''Number suffix
useEasingBooleantrueWhether to use easing function
easingFnArray[0.2, 0.2, 0, 1]Custom easing function parameters

Events

Event NameDescriptionParameters
update:modelValueTriggered when component value changesCurrent number value (Number)

TIP

  1. Component uses useTransition hook internally to achieve smooth transition animation, supports custom easing functions.
  2. Can add units or symbols through prefix and suffix properties, such as: "$1,000.00 USD".
  3. Supports custom thousand separator and decimal point symbol, adapts to number formats in different regions.
  4. Can control displayed decimal places through decimals property, default shows no decimals.
  5. When autoplay is true, component will automatically start animation when properties change.

湘ICP备2024070110号