Skip to content

数字翻滚 xRollingNumber


在线预览
在线模拟尺寸:

介绍

是否小数点,取决与你的的endVal目标值,如果它带小数点,那动画也是相应带小数点。

平台兼容

HarmonyH5andriodIOS小程序UTSUNIAPP-X SDKversion
☑️☑️☑️☑️4.76+1.1.18

文件路径

ts

@/uni_modules/tmx-ui/components/x-rolling-number/x-rolling-number.uvue

使用

ts

<x-rolling-number></x-rolling-number>

Props 属性

名称说明类型默认值
fontSize文字大小
string"32"
fontColor文字颜色
string"black"
darkFontColor暗黑时的文字颜色,如果为空取白
string""
startVal起始值
number0
endVal目标值(当前需要显示的值)
number0
duration动画速率。控制翻滚动的动画效果。
number600
easing缓动函数类型
string"easeIn"
useGrouping是否显示千分位分隔符
booleanfalse
decimals小数位数
number-1
prefix前缀符号(如货币符号)
string""
suffix后缀符号(如单位)
string""
enableAnimation是否启用动画
booleantrue

Events 事件

名称参数说明
animationStart-动画开始时触发
animationComplete-动画完成时触发
animationPause-动画暂停时触发
animationResume-动画恢复时触发
animationStop-动画停止时触发
valueChange-数值变化时触发

Slots 插槽

名称说明数据
default默认插槽value: string
value: string
formattedValue: string
formattedValue: string

Ref 方法

名称参数返回值说明
play--播放动画 *
pause--暂停动画 *
resume--恢复动画 *
stop--停止动画 *
reset--重置到起始值 *
isAnimating--是否正在动画中 *
getValue--获取当前值 *
getFormattedValue--获取格式化后的值 *

示例文件路径

json

/pages/zhanshi/rolling-number

示例源码

uvue
vue
<template>
	<!-- #ifdef APP -->
	<scroll-view style="flex:1">
	<!-- #endif -->
	<!-- #ifdef MP-WEIXIN -->
	<page-meta :page-style="`background-color:${xThemeConfigBgColor}`">
		<navigation-bar :background-color="xThemeConfigNavBgColor" :front-color="xThemeConfigNavFontColor"></navigation-bar>
	</page-meta>
	<!-- #endif -->
		<x-sheet>
			<x-text font-size="18" class=" text-weight-b mb-8">数字翻滚 xRollingNumber</x-text>
			<x-text color="#999999" >
				是否小数点,取决与你的的endVal目标值,如果它带小数点,那动画也是相应带小数点。
			</x-text>
		</x-sheet>
		<x-sheet>
			<x-text font-size="18" class=" text-weight-b mb-8">小数</x-text>
			<x-rolling-number :endVal="endVal"></x-rolling-number>
			<x-button class="mt-32" :block="true" @click="endVal=endVal+12">增加+12</x-button>
		</x-sheet>
		
		<x-sheet>
			<x-text font-size="18" class=" text-weight-b mb-8">整数,让动画时间加长点{{endVal2}}</x-text>
			<x-rolling-number :endVal="endVal2" :duration="1100"></x-rolling-number>
			<x-button class="mt-32" :block="true" @click="endVal2=endVal2+122">增加+122</x-button>
		</x-sheet>

	<!-- #ifdef APP -->
	</scroll-view>
	<!-- #endif -->
</template>

<script>
	export default {

		data() {
			return {
				endVal:2023.2,
				endVal2:1998,
			};
		},
		onLoad() {
			
		}
	}
</script>

<style lang="scss">

</style>
最近更新