分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 技术分享

countUp.js

发布时间:2023-09-06 01:30责任编辑:彭小芳关键词:js

项目链接:http://inorganik.github.io/countUp.js

countUp.js网上教程已经有很多了,但很多只是提供了一个接口方法,现在做个详细的说明,便于新手快速如梦。

导入countUp.js

HTML语句:

<span id="dayCar" style="font-size: 28px;color: yellow;" >0</span>

js代码:

window.onload = function () { ???????????startDayCar(); ???????}; ???????function startDayCar(){ ???????????????????????var options = { ???????????????useEasing: true, ????????????????useGrouping: true, ????????????????separator: ‘,‘, ????????????????decimal: ‘.‘, ????????????}; ???????????var demo = new CountUp(‘dayCar‘, 0, 25, 0, 2.5, options); ???????????if (!demo.error) { ???????????????demo.start(); ???????????} else { ???????????????console.error(demo.error); ???????????} ???????}

CountUp对象5个差数对应

target = id of html element or var of previously selected html element where counting occurs
startVal = the value you want to begin at
endVal = the value you want to arrive at
decimals = number of decimal places, default 0
duration = duration of animation in seconds, default 2
options = optional object of options (see below)

Options 

useEasing: true, // toggle easing
useGrouping: true, // 1,000,000 vs 1000000
separator: ‘,‘, // character to use as a separator
decimal: ‘.‘, // character to use as a decimal
easingFn: easeOutExpo, // optional custom easing function, default is Robert Penner‘s easeOutExpo
formattingFn: formatNumber, // optional custom formatting function, default is formatNumber above
prefix: ‘‘, // optional text before the result
suffix: ‘‘, // optional text after the result
numerals: [] // optionally pass an array of custom numerals for 0-9

countUp.js

原文地址:http://www.cnblogs.com/congyu/p/8028437.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved