最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

 更新時間:2022年10月05日 08:49:42   作者:河北小寶  
大家應該都知道,Swiper是純javascript打造的滑動特效插件,面向手機、平板電腦等移動終端,下面這篇文章主要給大家介紹了關(guān)于Swiper如何實現(xiàn)兩行四列輪播圖效果的相關(guā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:"http://s.qunarzz.com/homenode/images/touchheader/hotel.png",
          text:"酒店"
        },
        {
          id:"02",
          imgUrl:"http://s.qunarzz.com/homenode/images/touchheader/flight.png",
          text:"機票"
        },
        {
          id:"03",
          imgUrl:"http://s.qunarzz.com/homenode/images/touchheader/train.png",
          text:"火車票"
        },
        {
          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:"景點門票"
        }
        ,{
          id:"06",
          imgUrl:"http://s.qunarzz.com/homenode/images/touchheader/hotel.png",
          text:"景點門票"
        }
        ,{
          id:"07",
          imgUrl:"http://s.qunarzz.com/homenode/images/touchheader/hotel.png",
          text:"景點門票"
        }
        ,{
          id:"08",
          imgUrl:"http://s.qunarzz.com/homenode/images/touchheader/hotel.png",
          text:"景點門票"
        }
        ,{
          id:"09",
          imgUrl:"http://s.qunarzz.com/homenode/images/touchheader/hotel.png",
          text:"景點門票"
        }
        ,{
          id:"10",
          imgUrl:"http://s.qunarzz.com/homenode/images/touchheader/hotel.png",
          text:"景點門票"
        }
      ],
      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) 用來將這些圖片文字 以八個為單位分別拆開 從而實現(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>

先遍歷以八個為單位的數(shù)組 然后在遍歷里面的內(nèi)容

總結(jié)

到此這篇關(guān)于Swiper如何實現(xiàn)兩行四列輪播圖效果的文章就介紹到這了,更多相關(guān)Swiper兩行四列輪播圖內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評論

新干县| 鹤庆县| 澳门| 泾阳县| 昆山市| 陆良县| 五家渠市| 苏尼特左旗| 搜索| 平阴县| 滨海县| 上栗县| 黑龙江省| 全南县| 高淳县| 搜索| 于田县| 奈曼旗| 沙田区| 高阳县| 麟游县| 蓬溪县| 江都市| 澄城县| 滨海县| 延川县| 平潭县| 拉孜县| 嵊泗县| 石河子市| 工布江达县| 改则县| 建昌县| 嘉黎县| 桐庐县| 师宗县| 望江县| 万州区| 靖边县| 平顺县| 繁昌县|