您好,登錄后才能下訂單哦!
這篇文章主要講解了“Swiper怎么實(shí)現(xiàn)兩行四列輪播圖效果”,文中的講解內(nèi)容簡單清晰,易于學(xué)習(xí)與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學(xué)習(xí)“Swiper怎么實(shí)現(xiàn)兩行四列輪播圖效果”吧!
.icons{ width:100%; overflow: hidden; } .icons-item{ width: 25%; height: 0; padding-bottom: 25%; float: left; } .icons-item img{ width: 1.1rem; height: 1.1rem; display: block; margin: 0 auto; padding-top: .2rem; } .icons-item p{ margin-top: .1rem; font-size: .28rem; text-align: center; color: #212121; }
<script type="text/javascript"> export default { data(){ return { swiperOption:{}, iconsList:[ { id:"01", imgUrl:"//s.qunarzz.com/homenode/images/touchheader/hotel.png", text:"酒店" }, { id:"02", imgUrl:"//s.qunarzz.com/homenode/images/touchheader/flight.png", text:"機(jī)票" }, { id:"03", imgUrl:"//s.qunarzz.com/homenode/images/touchheader/train.png", text:"火車票" }, { id:"04", imgUrl:"//s.qunarzz.com/homenode/images/touchheader/package.png", text:"度假" } ,{ id:"05", imgUrl:"//s.qunarzz.com/homenode/images/touchheader/hotel.png", text:"景點(diǎn)門票" } ,{ id:"06", imgUrl:"//s.qunarzz.com/homenode/images/touchheader/hotel.png", text:"景點(diǎn)門票" } ,{ id:"07", imgUrl:"//s.qunarzz.com/homenode/images/touchheader/hotel.png", text:"景點(diǎn)門票" } ,{ id:"08", imgUrl:"//s.qunarzz.com/homenode/images/touchheader/hotel.png", text:"景點(diǎn)門票" } ,{ id:"09", imgUrl:"//s.qunarzz.com/homenode/images/touchheader/hotel.png", text:"景點(diǎn)門票" } ,{ id:"10", imgUrl:"//s.qunarzz.com/homenode/images/touchheader/hotel.png", text:"景點(diǎn)門票" } ], swiperOption:{ // 設(shè)置分頁器 pagination: { el: '.swiper-pagination', } } } }, computed:{ page(){ let pages = []; this.iconsList.forEach((item,index)=>{ let idx = Math.floor(index/8) if(!pages[idx]) pages[idx] =[]; pages[idx].push(item) }) return pages } } } </script>
需要注意的是 let idx = Math.floor(index/8) if(!pages[idx]) pages[idx] =[]; pages[idx].push(item) 用來將這些圖片文字 以八個為單位分別拆開 從而實(shí)現(xiàn)最重要的效果
<div class="icons"> <swiper ref="mySwiper" :options="swiperOption"> <swiper-slide v-for='item in page' :key='item.id'> <div v-for="page in item" :key="page.id" class="icons-item"> <img :src="page.imgUrl"> <p>{{page.text}}</p> </div> </swiper-slide> <div class="swiper-pagination" slot="pagination"></div> </swiper> </div>
先遍歷以八個為單位的數(shù)組 然后在遍歷里面的內(nèi)容
感謝各位的閱讀,以上就是“Swiper怎么實(shí)現(xiàn)兩行四列輪播圖效果”的內(nèi)容了,經(jīng)過本文的學(xué)習(xí)后,相信大家對Swiper怎么實(shí)現(xiàn)兩行四列輪播圖效果這一問題有了更深刻的體會,具體使用情況還需要大家實(shí)踐驗(yàn)證。這里是億速云,小編將為大家推送更多相關(guān)知識點(diǎn)的文章,歡迎關(guān)注!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。