Skip to content
On this page

DigitalScroll 滚动数字

滚动数字,用于展示数字的变化。

基础用法

number属性表示要展示的数字,digit属性表示保留多少位小数

切换数字
<template>
  <div>
    <FDigitalScroll :number="num" :digit="2"></FDigitalScroll>
    <FDigitalScroll :number="num" :digit="3"></FDigitalScroll>
    <div class="toggle-btn" @click="clickToggleBtn">切换数字</div>
  </div>
</template>
<script lang="ts" setup>
import { ref } from 'vue';

let num = ref(100.999)
const clickToggleBtn = () =>{
  if(num.value === 100.999){
    num.value = 999
  }else {
    num.value = 100.999
  }
}
</script>
<style>
.toggle-btn{
  width:100px;
  padding:5px 15px;
  background: rgb(33, 150, 243);
  border-radius: 5px;
  cursor: pointer;
}
</style>

参数

参数名说明类型可选值默认值
num展示的数字number-0
digit保留多少位小数number-2