您好,登錄后才能下訂單哦!
這篇文章主要介紹了vue版數(shù)字翻牌器怎么封裝的相關(guān)知識(shí),內(nèi)容詳細(xì)易懂,操作簡(jiǎn)單快捷,具有一定借鑒價(jià)值,相信大家閱讀完這篇vue版數(shù)字翻牌器怎么封裝文章都會(huì)有所收獲,下面我們一起來(lái)看看吧。
封裝vue版數(shù)字翻牌器
<template> <div class="number"> <ul id="dataNums"> <li v-for="(item,index) in list" :key="index"> <div class="dataBoc"> <div class="tt" :> <span v-for="(item2,index2) in numList" :key="index2">{{item2}} </span> </div> </div> </li> </ul> </div> </template>
js部分
export default { props:{ number:Number }, data(){ return{ list:[], numList: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, '.'] } }, mounted(){ this.scroll(); }, methods:{ scroll(){ this.list=this.number.toString().split(''); let arr=[]; this.list.forEach((value) => { arr.push({ num:value, top:0 }) }); this.list=arr; let Hei=parseFloat(getComputedStyle(document.getElementById("dataNums")).height); this.list.forEach((value,index) => { setTimeout(()=>{ value.top=parseFloat((value.num*Hei)+(Hei*10)); },index*300); }); } } }
css樣式
.number { margin-bottom: 10px; text-align: center; ul { display: inline-block; height: 40px; text-align: center; li { float: left; width: 40px; height: 40px; text-align: center; margin: 0 4px; background: url("../assets/images/yuyueshf/number.png") no-repeat center;//背景圖 background-size: 100% 100%; .dataBoc { position: relative; width: 100%; height: 100%; overflow: hidden; .tt { position: absolute; top: 0; left: 0; width: 100%; height: 100%; span{ width: 100%; height: 100%; line-height: 40px; float: left; text-align: center; font-size: 26px; color: #f64841; } } } } } }
關(guān)于“vue版數(shù)字翻牌器怎么封裝”這篇文章的內(nèi)容就介紹到這里,感謝各位的閱讀!相信大家對(duì)“vue版數(shù)字翻牌器怎么封裝”知識(shí)都有一定的了解,大家如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。