Skip to content
本页导读

CountTo 数字滚动

组件类型:UxCounttoComponentPublicInstance

支持设置滚动时间,可显示小数

平台兼容性

AndroidiOSweb鸿蒙 Next小程序
xx

Props

属性名类型默认值说明
themeStringprimary主题颜色
startValNumber0开始的数值
endValNumber0要滚动的目标数值
durationNumber2000滚动到目标数值的动画持续时间,单位为毫秒 (ms)
millisecondBooleanfalse是否展示毫秒倒计时
autoplayBooleantrue设置数值后是否自动开始滚动
decimalsNumber0要显示的小数位数
colorString$ux.Conf.fontColor字体颜色
darkColorString-深色
sizeNumber$ux.Conf.fontSize字体大小
boldBooleanfalse字体是否加粗

theme

说明
primary主色
warning警告
success成功
error错误
info文本

darkColor

说明
none不显示
auto自动适配深色模式
color其他颜色

Events

事件名说明参数
end数值滚动到目标值时触发event: Function

示例代码

html
<template>
	<ux-page>
		<ux-navbar :title="title" :border="false"></ux-navbar>
		
		<ux-scroll>
			<ux-card direction="column" icon="flag" title="数字滚动" :bold="true">
				<ux-text text="支持设置滚动时间,可显示小数"></ux-text>
				<ux-row :flex="true" align="top" :mt="5" style="width: 100%;">
					<ux-text text="详细文档:"></ux-text>
					<ux-text style="flex: 1" name="数字滚动" text="https://www.uxframe.cn/component/display/countto.html" mode="link"></ux-text>
				</ux-row>
			</ux-card>
			
			<ux-card direction="column" icon="arrowright" title="主题" :bold="true">
				<ux-text text="多种主题可配置,适配暗黑模式" :mb="15"></ux-text>
				<ux-row>
					<ux-countto theme="success" :startVal="0" :endVal="5000" :duration="2000"></ux-countto>
					<ux-countto theme="warning" :startVal="0" :endVal="5000" :duration="2000" :ml="10"></ux-countto>
				</ux-row>
			</ux-card>
			
			<ux-card direction="column" icon="arrowright" title="小数" :bold="true">
				<ux-text text="支持小数显示,可精确小数位数" :mb="15"></ux-text>
				<ux-row>
					<ux-countto theme="success" :decimals="2"></ux-countto>
					<ux-countto theme="warning" :decimals="4" :ml="10"></ux-countto>	
				</ux-row>
			</ux-card>
			
			<ux-card direction="column" icon="arrowright" title="自由控制" :bold="true">
				<ux-text text="支持控制动画播放" :mb="15"></ux-text>
				<ux-col>
					<ux-countto ref="uxCounttoRef" :autoplay="false"></ux-countto>
					
					<ux-button theme="primary" :mt="10" text="开始" @click="start"></ux-button>
					<ux-button theme="success" :mt="10" text="暂停" @click="pause"></ux-button>
					<ux-button theme="warning" :mt="10" text="继续" @click="resume"></ux-button>
					<ux-button theme="error" :mt="10" text="停止" @click="stop"></ux-button>
				</ux-col>
			</ux-card>
			
			<ux-placeholder :height="200">
				<ux-row justify="center" align="center" style="height: 100%;">
					<ux-text prefix-icon="wink" text="真的没有了~"></ux-text>
				</ux-row>
			</ux-placeholder>
		</ux-scroll>
		
	</ux-page>
</template>
<template>
	<ux-page>
		<ux-navbar :title="title" :border="false"></ux-navbar>
		
		<ux-scroll>
			<ux-card direction="column" icon="flag" title="数字滚动" :bold="true">
				<ux-text text="支持设置滚动时间,可显示小数"></ux-text>
				<ux-row :flex="true" align="top" :mt="5" style="width: 100%;">
					<ux-text text="详细文档:"></ux-text>
					<ux-text style="flex: 1" name="数字滚动" text="https://www.uxframe.cn/component/display/countto.html" mode="link"></ux-text>
				</ux-row>
			</ux-card>
			
			<ux-card direction="column" icon="arrowright" title="主题" :bold="true">
				<ux-text text="多种主题可配置,适配暗黑模式" :mb="15"></ux-text>
				<ux-row>
					<ux-countto theme="success" :startVal="0" :endVal="5000" :duration="2000"></ux-countto>
					<ux-countto theme="warning" :startVal="0" :endVal="5000" :duration="2000" :ml="10"></ux-countto>
				</ux-row>
			</ux-card>
			
			<ux-card direction="column" icon="arrowright" title="小数" :bold="true">
				<ux-text text="支持小数显示,可精确小数位数" :mb="15"></ux-text>
				<ux-row>
					<ux-countto theme="success" :decimals="2"></ux-countto>
					<ux-countto theme="warning" :decimals="4" :ml="10"></ux-countto>	
				</ux-row>
			</ux-card>
			
			<ux-card direction="column" icon="arrowright" title="自由控制" :bold="true">
				<ux-text text="支持控制动画播放" :mb="15"></ux-text>
				<ux-col>
					<ux-countto ref="uxCounttoRef" :autoplay="false"></ux-countto>
					
					<ux-button theme="primary" :mt="10" text="开始" @click="start"></ux-button>
					<ux-button theme="success" :mt="10" text="暂停" @click="pause"></ux-button>
					<ux-button theme="warning" :mt="10" text="继续" @click="resume"></ux-button>
					<ux-button theme="error" :mt="10" text="停止" @click="stop"></ux-button>
				</ux-col>
			</ux-card>
			
			<ux-placeholder :height="200">
				<ux-row justify="center" align="center" style="height: 100%;">
					<ux-text prefix-icon="wink" text="真的没有了~"></ux-text>
				</ux-row>
			</ux-placeholder>
		</ux-scroll>
		
	</ux-page>
</template>
ts
<script setup>
	let title = ''
	
	const uxCounttoRef = ref<UxCounttoComponentPublicInstance | null>(null)
	
	onLoad((e: OnLoadOptions) => {
		title = e['title'] ?? ''
	})
	
	function start() {
		uxCounttoRef.value!.start()
	}
	
	function pause() {
		uxCounttoRef.value!.pause()
	}
	
	function resume() {
		uxCounttoRef.value!.resume()
	}
	
	function stop() {
		uxCounttoRef.value!.stop()
	}
</script>
<script setup>
	let title = ''
	
	const uxCounttoRef = ref<UxCounttoComponentPublicInstance | null>(null)
	
	onLoad((e: OnLoadOptions) => {
		title = e['title'] ?? ''
	})
	
	function start() {
		uxCounttoRef.value!.start()
	}
	
	function pause() {
		uxCounttoRef.value!.pause()
	}
	
	function resume() {
		uxCounttoRef.value!.resume()
	}
	
	function stop() {
		uxCounttoRef.value!.stop()
	}
</script>
css
<style lang="scss">
	
</style>
<style lang="scss">
	
</style>