Swiper如何實(shí)現(xiàn)兩行四列輪播圖效果實(shí)例
案例效果

基本樣式
.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:"http://s.qunarzz.com/homenode/images/touchheader/hotel.png",
text:"酒店"
},
{
id:"02",
imgUrl:"http://s.qunarzz.com/homenode/images/touchheader/flight.png",
text:"機(jī)票"
},
{
id:"03",
imgUrl:"http://s.qunarzz.com/homenode/images/touchheader/train.png",
text:"火車(chē)票"
},
{
id:"04",
imgUrl:"http://s.qunarzz.com/homenode/images/touchheader/package.png",
text:"度假"
}
,{
id:"05",
imgUrl:"http://s.qunarzz.com/homenode/images/touchheader/hotel.png",
text:"景點(diǎn)門(mén)票"
}
,{
id:"06",
imgUrl:"http://s.qunarzz.com/homenode/images/touchheader/hotel.png",
text:"景點(diǎn)門(mén)票"
}
,{
id:"07",
imgUrl:"http://s.qunarzz.com/homenode/images/touchheader/hotel.png",
text:"景點(diǎn)門(mén)票"
}
,{
id:"08",
imgUrl:"http://s.qunarzz.com/homenode/images/touchheader/hotel.png",
text:"景點(diǎn)門(mén)票"
}
,{
id:"09",
imgUrl:"http://s.qunarzz.com/homenode/images/touchheader/hotel.png",
text:"景點(diǎn)門(mén)票"
}
,{
id:"10",
imgUrl:"http://s.qunarzz.com/homenode/images/touchheader/hotel.png",
text:"景點(diǎn)門(mén)票"
}
],
swiperOption:{
// 設(shè)置分頁(yè)器
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) 用來(lái)將這些圖片文字 以八個(gè)為單位分別拆開(kāi) 從而實(shí)現(xiàn)最重要的效果
循環(huá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>先遍歷以八個(gè)為單位的數(shù)組 然后在遍歷里面的內(nèi)容
總結(jié)
到此這篇關(guān)于Swiper如何實(shí)現(xiàn)兩行四列輪播圖效果的文章就介紹到這了,更多相關(guān)Swiper兩行四列輪播圖內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
防止網(wǎng)站內(nèi)容被拷貝的一些方法與優(yōu)缺點(diǎn)好處與壞處分析
防止網(wǎng)站內(nèi)容被拷貝的一些方法與優(yōu)缺點(diǎn)好處與壞處分析...2007-11-11
使用Promise和JavaScript有效處理1000個(gè)請(qǐng)求的方法
在現(xiàn)代Web開(kāi)發(fā)中,處理高并發(fā)請(qǐng)求是一個(gè)常見(jiàn)的挑戰(zhàn),當(dāng)我們需要從服務(wù)器獲取大量數(shù)據(jù)或執(zhí)行多個(gè)異步任務(wù)時(shí),如何有效地管理請(qǐng)求的并發(fā)性和性能變得至關(guān)重要,本文將介紹如何使用Promise和JavaScript來(lái)管理高并發(fā)請(qǐng)求,需要的朋友可以參考下2023-09-09
KnockoutJS 3.X API 第四章之?dāng)?shù)據(jù)控制流if綁定和ifnot綁定
這篇文章主要介紹了KnockoutJS 3.X API 第四章之?dāng)?shù)據(jù)控制流if綁定和ifnot綁定的相關(guān)資料,需要的朋友可以參考下2016-10-10
JS實(shí)現(xiàn)顯示帶倒影的圖片橫排居中放大展示特效實(shí)例【測(cè)試可用】
這篇文章主要介紹了JS實(shí)現(xiàn)顯示帶倒影的圖片橫排居中放大展示功能,可實(shí)現(xiàn)點(diǎn)擊圖片及點(diǎn)擊左右按鈕滑動(dòng)切換的效果,涉及javascript針對(duì)鼠標(biāo)事件的響應(yīng)及頁(yè)面元素動(dòng)態(tài)操作相關(guān)技巧,需要的朋友可以參考下2016-08-08
js實(shí)現(xiàn)網(wǎng)頁(yè)標(biāo)題欄閃爍提示效果實(shí)例分析
這篇文章主要介紹了js實(shí)現(xiàn)網(wǎng)頁(yè)標(biāo)題欄閃爍提示效果的方法,以實(shí)例形式分析了網(wǎng)上比較常見(jiàn)的實(shí)現(xiàn)方法,并對(duì)于原理進(jìn)行分析并加以改進(jìn),最后給出了一個(gè)具體的應(yīng)用實(shí)例供大家參考,需要的朋友可以參考下2014-11-11
window.location.hash 屬性使用說(shuō)明
location是javascript里邊管理地址欄的內(nèi)置對(duì)象,比如location.href就管理頁(yè)面的url,用location.href=url就可以直接將頁(yè)面重定向url。而location.hash則可以用來(lái)獲取或設(shè)置頁(yè)面的標(biāo)簽值。2010-03-03

