日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 前端技术 > vue >内容正文

vue

vue数字滚动效果组件

發(fā)布時(shí)間:2023/12/20 vue 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 vue数字滚动效果组件 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

數(shù)字滾動(dòng)變化效果組件

效果

預(yù)覽

體驗(yàn)地址

用途

  • 大屏展示,數(shù)字滾動(dòng)效果

實(shí)現(xiàn)

使用js控制元素移動(dòng)。
關(guān)鍵代碼如下:

//修改 chang(oldVal,newVal,id){if(oldVal >= newVal) return;let stepTime = this.stepTime;let time = Math.ceil((newVal - oldVal) / this.fontSize);time = stepTime / time;const dom = document.getElementById(id);// console.log(oldVal,newVal,id,dom);// console.log('time',time);oldVal += 0.5;if(oldVal >= 20){oldVal %= 20;newVal %= 20;}if(oldVal >= 10){oldVal %= 10;newVal %= 10;if(newVal < oldVal) newVal += 10;}dom.style.bottom = oldVal * this.fontSize + 'rem';setTimeout(()=>{this.chang(oldVal,newVal,id);},time); }, //數(shù)據(jù)變化時(shí)觸發(fā),處理變化后的數(shù)據(jù) numRolling(newVal,oldVal){this.oldVal = newVal;oldVal = parseFloat(oldVal).toFixed(this.fixNum).toString().split('');newVal = parseFloat(newVal).toFixed(this.fixNum).toString().split('');let headNum = this.headNum;//數(shù)位發(fā)生變化,前面補(bǔ)零while(oldVal.length < newVal.length){oldVal.unshift('0');headNum--;document.getElementById('num-content'+headNum).parentNode.style.display = 'flex';}//修改前置位標(biāo)記數(shù)this.headNum = headNum;for(let i = 0; i < newVal.length; i++){let num = parseInt(newVal[i]);if(num >= 0 && num <= 9 ){let oldV = parseFloat(oldVal[i]),newV = parseFloat(newVal[i]);if(oldV > newV) newV += 10;this.chang(oldV,newV,'num-content'+(i + headNum));}} }

npm引入

組件以上傳到npm,可以直接install使用

1.安裝

npm i @jyeontu/jvuewheel -S

2.引入

//引入組件庫(kù) import jvuewheel from '@jyeontu/jvuewheel' //引入樣式 import '@jyeontu/jvuewheel/lib/jvuewhell.css' Vue.use(jvuewheel);

3.vue中引用組件

<j-num-rolling :nums = "nums" :fixNum = "2" :stepTime = "200" :refreshTime = "2" :fontSize = "4" :numStyle = "numStyle"> </j-num-rolling>

資源地址

組件文檔

文檔地址:http://120.79.163.94/JYeontuComponents/#/homePage

代碼地址

Gitee:https://gitee.com/zheng_yongtao/jyeontu-component-warehouse/tree/master/JYeontuComponentWarehouse

總結(jié)

以上是生活随笔為你收集整理的vue数字滚动效果组件的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。