亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

vue實現(xiàn)帶縮略圖的輪播圖效果

 更新時間:2024年02月01日 10:01:36   作者:lllomh  
這篇文章主要為大家詳細介紹了如何使用vue實現(xiàn)帶縮略圖的輪播圖效果,文中的示例代碼講解詳細,具有一定的借鑒價值,有需要的可以參考下

1.引入swiper和vue-awesome-swiper插件

npm install swiper@4 --save
npm install vue-awesome-swiper@3 --save

2.在main.js中引入:

import VueAwesomeSwiper from 'vue-awesome-swiper'
 Vue.use(VueAwesomeSwiper)
 import '../node_modules/swiper/dist/css/swiper.css'

3.使用:

template:布局

<template>
  <div>
    <div class="thumb-example">
      <!-- swiper1 -->
      <swiper
              class="swiper gallery-top"
              :options="swiperOptionTop"
              ref="swiperTop"
      >
        <swiper-slide class="slide-1" v-for="item in bigImg" :key="item.id">
          <img :src="item.url" style="height:570px;width:100%" alt="" />
        </swiper-slide>
        <div
                class="swiper-button-next swiper-button-white"
                slot="button-next"
        ></div>
        <div
                class="swiper-button-prev swiper-button-white"
                slot="button-prev"
        ></div>
      </swiper>
      <!-- swiper2 Thumbs -->
      <swiper
              class="swiper gallery-thumbs"
              :options="swiperOptionThumbs"
              ref="swiperThumbs"
      >
        <swiper-slide
                class="slide"
                style="width:100px;height:100px;"
                v-for="item in bigImg"
                :key="item.id"
        >
          <img style="width:100px;height:100px;" :src="item.url" alt="" />
        </swiper-slide>
        <div class="swiper-button-next swiper-button-white" slot="button-next">
          <div>
            <img src="../assets/ArtIcon-offs.svg" alt="" />
          </div>
        </div>
        <div class="swiper-button-prev swiper-button-white" slot="button-prev">
          <div>
            <img src="../assets/ArtIcon-offs.svg" alt="" />
          </div>
        </div>
      </swiper>
    </div>
  </div>
</template>
 
<script>
export default {
  mounted() {
    // 實現(xiàn)swiper雙向控制
    this.$nextTick(() => {
      const swiperTop = this.$refs.swiperTop.swiper
      const swiperThumbs = this.$refs.swiperThumbs.swiper
      swiperTop.controller.control = swiperThumbs
      swiperThumbs.controller.control = swiperTop
    })
  },
  data() {
    return {
      //輪播大圖配置
      bigImg: [
        {
          url: 'https://bhw.lllomh.com/images/02.jpg',
          id: 0
        },
        {
          url: 'https://bhw.lllomh.com/images/01.jpg',
          id: 1
        },
        {
          url: 'https://bhw.lllomh.com/images/03.jpg',
          id: 2
        },
        {
          url: 'https://bhw.lllomh.com/images/04.jpg',
          id: 3
        }
      ],
      swiperOptionTop: {
        zoom: true,
        loop: true,
        loopedSlides: 5, // looped slides should be the same
        spaceBetween: 10,
        observer: true, //修改swiper自己或子元素時,自動初始化swiper
        observeParents: true, //修改swiper的父元素時,自動初始化swiper
        // autoplay: {  //自動輪播
        //   delay: 2000,
        //   disableOnInteraction: false
        // },
        navigation: {
          nextEl: '.swiper-button-next',
          prevEl: '.swiper-button-prev'
        }
      },
      swiperOptionThumbs: {
        loop: true,
        loopedSlides: 5, // looped slides should be the same
        spaceBetween: 10,
        centeredSlides: true,
        slidesPerView: 'auto',
        touchRatio: 0.2,
        slideToClickedSlide: true,
        navigation: {
          nextEl: '.swiper-button-next',
          prevEl: '.swiper-button-prev'
        }
      }
    }
  },
 
  methods: {}
}
</script>

4.scss or sass

<style lang="scss" scoped>
h3 {
  margin: 20px 0 0 10px;
}
.thumb-example {
  width: 864px;
  margin-top: 20px;
  // background: #000;
}
.swiper-slide {
  background-size: cover;
  background-position: center;
}
.gallery-top {
  // height: 80% !important;
  height: 600px;
  width: 100%;
}
.gallery-thumbs {
  height: 20% !important;
  box-sizing: border-box;
  padding: 10px 0px;
  width: 864px;
  margin-left: 2px;
  .swiper-button-next {
    right: 0px;
  }
  .swiper-button-prev {
    left: 0px;
  }
  .swiper-button-next,
  .swiper-button-prev {
    background: #fff;
    width: 45px;
    text-align: center;
    height: 101px;
    top: 26%;
    div {
      margin-top: 30px;
      background: rgb(207, 205, 205);
      height: 45px;
      border-radius: 50%;
      img {
        margin: 7px 0 0 2px;
        width: 30px;
      }
    }
  }
  .swiper-button-next:hover div {
    background: rgb(189, 186, 186);
  }
  .swiper-button-prev:hover div {
    background: rgb(189, 186, 186);
  }
}
.gallery-thumbs .swiper-slide {
  width: 20%;
  height: 80px;
  // opacity: 0.4;
}
.gallery-thumbs .swiper-slide-active {
  border: 2px solid red;
}
</style>

這樣就可以了

效果:

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

相關(guān)文章

  • vue菜單欄聯(lián)動內(nèi)容頁面tab的實現(xiàn)示例

    vue菜單欄聯(lián)動內(nèi)容頁面tab的實現(xiàn)示例

    本文主要介紹了vue菜單欄聯(lián)動內(nèi)容頁面tab的實現(xiàn)示例,左側(cè)菜單欄與右側(cè)內(nèi)容部分聯(lián)動,當(dāng)點擊左側(cè)的菜單,右側(cè)會展示對應(yīng)的tab,具有一定的參考價值,感興趣的可以了解一下
    2024-01-01
  • vue項目配置同一局域網(wǎng)可使用ip訪問的操作

    vue項目配置同一局域網(wǎng)可使用ip訪問的操作

    這篇文章主要介紹了vue項目配置同一局域網(wǎng)可使用ip訪問的操作,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-10-10
  • Vue項目導(dǎo)入導(dǎo)出文件功能以及導(dǎo)出文件后亂碼問題及解決

    Vue項目導(dǎo)入導(dǎo)出文件功能以及導(dǎo)出文件后亂碼問題及解決

    這篇文章主要介紹了Vue項目導(dǎo)入導(dǎo)出文件功能以及導(dǎo)出文件后亂碼問題及解決方案,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-09-09
  • Vue組件之間的參數(shù)傳遞與方法調(diào)用的實例詳解

    Vue組件之間的參數(shù)傳遞與方法調(diào)用的實例詳解

    這篇文章主要介紹了Vue組件之間的參數(shù)傳遞與方法調(diào)用,本文通過實例代碼給大家介紹的非常詳細,對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2022-12-12
  • vue前端開發(fā)keepAlive使用詳解

    vue前端開發(fā)keepAlive使用詳解

    在開發(fā)中經(jīng)常有從列表跳到詳情頁,然后返回詳情頁的時候需要緩存列表頁的狀態(tài)(比如滾動位置信息),這個時候就需要保存狀態(tài),要緩存狀態(tài)
    2021-10-10
  • vue給組件傳遞不同的值方法

    vue給組件傳遞不同的值方法

    今天小編就為大家分享一篇vue給組件傳遞不同的值方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2018-09-09
  • 關(guān)于vue利用postcss-pxtorem進行移動端適配的問題

    關(guān)于vue利用postcss-pxtorem進行移動端適配的問題

    這篇文章主要介紹了關(guān)于vue利用postcss-pxtorem進行移動端適配的問題,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-11-11
  • Vue API中setup ref reactive函數(shù)使用教程

    Vue API中setup ref reactive函數(shù)使用教程

    setup是用來寫組合式api,內(nèi)部的數(shù)據(jù)和方法需要通過return之后,模板才能使用。在之前vue2中,data返回的數(shù)據(jù),可以直接進行雙向綁定使用,如果我們把setup中數(shù)據(jù)類型直接雙向綁定,發(fā)現(xiàn)變量并不能實時響應(yīng)。接下來就詳細看看它們的使用
    2022-12-12
  • Vue.js中vue-property-decorator的使用方法詳解

    Vue.js中vue-property-decorator的使用方法詳解

    vue-property-decorator是一個用于在Vue.js中使用TypeScript裝飾器的庫,它能夠簡化 Vue 組件的定義,使代碼更加簡潔和可維護,它能夠簡化Vue組件的定義,使代碼更加簡潔和可維護,本文將深入探討vue-property-decorator的使用方法,并展示如何在Vue.js項目中應(yīng)用它
    2024-08-08
  • vue3實現(xiàn)圖片瀑布流展示效果實例代碼

    vue3實現(xiàn)圖片瀑布流展示效果實例代碼

    這篇文章主要介紹了vue3實現(xiàn)圖片瀑布流展示效果的相關(guān)資料,該組件可以調(diào)整列數(shù)、支持懶加載、自定義每頁滾動數(shù)量、高度和點擊效果,作者展示了組件的效果,并詳細說明了實現(xiàn)方法,包括組件的創(chuàng)建和依賴的工具庫,需要的朋友可以參考下
    2024-11-11

最新評論