countUp.js 实现数字动态变化的效果

1. countUp.js官网演示地址:http://inorganik.github.io/countUp.js/

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>数字增长效果</title>
</head>
<body>
    <h1 id="num1"></h1>
	<h1 id="num2"></h1>
	<h1 id="num3"></h1>
    
    <script src="https://cdn.bootcss.com/countup.js/1.9.3/countUp.js"></script>
    <script type="text/javascript">
        var options = {
            useEasing: true, 		// 使用缓和
            useGrouping: true, 		// 使用分组(是否显示千位分隔符,一般为 true)
            separator: ',', 		// 分隔器(千位分隔符,默认为',')
            decimal: '.', 			// 十进制(小数点符号,默认为 '.')
            prefix: '',				// 字首(数字的前缀,根据需要可设为 $,¥,¥ 等)
            suffix: '' 				// 后缀(数字的后缀 ,根据需要可设为 元,个,美元 等) 
        };
        
        		// CountUp(参数一, 参数二, 参数三, 参数四, 参数五, 参数六)
				// 参数一: 数字所在容器
				// 参数二: 数字开始增长前的默认值(起始值),一般从 0 开始增长
				// 参数三: 数字增长后的最终值,该值一般通过异步请求获取
				// 参数四: 数字小数点后保留的位数
				// 参数五: 数字增长特效的时间,此处为3秒
				// 参数六: 其他配置项
				// 注: 参数六也可不加,其配置项则为默认值

			new CountUp("num1", 0, 1380, 0, 3, options).start();
			new CountUp("num2", 0, 1380, 2, 3, options).start();
			new CountUp("num3", 0, 1380, 4, 3, options).start();
    </script>
</body>
</html>
  • 3
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值