首页
视频
资源
登录
小可爱
什么时候才能领悟,取之越多失之越多
博主信息
排名
6
文章
6
粉丝
16
评论
8
文章类别
ASP.NET
16篇
JS
1篇
.NET
23篇
英语
4篇
redis
4篇
随笔
30篇
EF
3篇
前端
53篇
.net core
25篇
python
8篇
版本控制
1篇
java
2篇
nginx
2篇
docker
6篇
后端
5篇
更多
mysql
8篇
数据库
15篇
微服务
4篇
移动开发
7篇
架构
6篇
linux
2篇
最新文章
最新评价
{{item.articleTitle}}
{{item.blogName}}
:
{{item.content}}
关于我们
ICP备案 :
渝ICP备18016597号-1
网站信息:
2018-2024
TNBLOG.NET
技术交流:
群号656732739
联系我们:
contact@tnblog.net
欢迎加群
欢迎加群交流技术
转
vue 实现数字滚动增加效果的实例代码
1890
人阅读
2023/3/11 11:12
总访问:
878015
评论:
0
收藏:
0
手机
分类:
前端
### 代码如下,可以直接运行 ``` <template> <div class="number-grow-warp"> <span ref="numberGrow" :data-time="time" class="number-grow" :data-value="value">0</span> </div> </template> <script> export default { props: { time: { type: Number, default: 2 }, value: { type: Number, default: 720000 } }, methods: { numberGrow (ele) { let _this = this let step = (_this.value * 10) / (_this.time * 1000) let current = 0 let start = 0 let t = setInterval(function () { start += step if (start > _this.value) { clearInterval(t) start = _this.value t = null } if (current === start) { return } current = start ele.innerHTML = current.toString().replace(/(\d)(?=(?:\d{3}[+]?)+$)/g, '$1,') }, 10) } }, mounted () { this.numberGrow(this.$refs.numberGrow) } } </script> <style> .number-grow-warp{ transform: translateZ(0); } .number-grow { font-family: Arial-BoldMT; font-size: 64px; color: #ffaf00; letter-spacing: 2.67px; margin:110px 0 20px; display: block; line-height:64px; } </style> ``` 当作组件使用 ``` <NumberGrow :value="720000"></NumberGrow> ``` 原文:https://www.zhangshengrong.com/p/Mr1WyO4ANG/
欢迎加群讨论技术,1群:677373950(满了,可以加,但通过不了),2群:656732739
👈{{preArticle.title}}
👉{{nextArticle.title}}
评价
{{titleitem}}
{{titleitem}}
{{item.content}}
{{titleitem}}
{{titleitem}}
{{item.content}}