一个小轮播图

简介: 一个小轮播图

用VUE3+Swipe实现了一个带缩略图的轮播图 展示为


代码如下:


<div class="swiper-box">
            <swiper :navigation="true" :modules="modules" class="mySwiper2" :loop="true"
              :thumbs="{ swiper: thumbsSwiper }">
              <swiper-slide v-for="item in supplyImg" :key="item">
                <img :src="item" alt="">
              </swiper-slide>
            </swiper>
            <swiper @swiper="setThumbsSwiper" :loop="true" :spaceBetween="10" :slidesPerView="3" :freeMode="true"
              :watchSlidesProgress="true" :modules="modules" class="mySwiper">
              <swiper-slide v-for="item in supplyImg" :key="item">
                <img :src="item" alt="">
              </swiper-slide>
            </swiper>
          </div>



export default {
    components: {
      Swiper,
      SwiperSlide,
    },
    setup () {
      const supplyData = ref({})
      const route = useRoute()
      const supplyId = route.params.supply_id
      const supplyImg = ref([])
      const supplyDetail = () => {
        console.log("supplyCategory~");
        getSupplynDetail(
          {
            supply_info: {
              supply_id: supplyId
            }
          },
          (status, res, data) => {
            supplyData.value = data.supply_infos[0]
            supplyImg.value = JSON.parse(supplyData.value.supply_scroll_images)
            console.log("supplyImg", supplyImg.value);
          },
          (status, error, msg) => {
            console.log('status: ', status)
            console.log('error: ', error)
            console.log('msg: ', msg)
            PromptMessage.messageBoxError('错误提示', msg)
          }
        )
      }
      let thumbsSwiper = ref(null);
      const setThumbsSwiper = (swiper) => {
        thumbsSwiper.value = swiper;
      }
      return {
        rate, modules: [Navigation, FreeMode, Thumbs],
        supplyDetail, supplyData, supplyId, supplyImg, thumbsSwiper, setThumbsSwiper
      }
    },
    mounted () {
      this.supplyDetail()
    }
  }



.swiper-box {
      width: 100%;
      height: 100%;
      margin-left: auto;
      margin-right: auto;
      margin-top: 30px;
      .swiper-slide {
        text-align: center;
        font-size: 18px;
        // background: #fff;
        /* Center slide text vertically */
        display: -webkit-box;
        display: -ms-flexbox;
        display: -webkit-flex;
        display: flex;
        -webkit-box-pack: center;
        -ms-flex-pack: center;
        -webkit-justify-content: center;
        justify-content: center;
        -webkit-box-align: center;
        -ms-flex-align: center;
        -webkit-align-items: center;
        align-items: center;
        background-size: cover;
        background-position: center;
        img {
          display: block;
          width: 100%;
          height: 100%;
          object-fit: cover;
        }
      }
      .mySwiper2 {
        position: relative;
        // float: left;
        height: 100%;
        width: 100%;
        border-radius: 12px;
      }
      .mySwiper {
        position: relative;
        margin-top: 5%;
        float: left;
        // margin-left: 3%;
        width: 100%;
        height: 70%;
        box-sizing: border-box;
        padding: 10px 0;
        .swiper-slide {
          width: 100%;
          height: 33%;
          opacity: 0.4;
          img {
            border-radius: 4%;
          }
        }
        .swiper-slide-thumb-active {
          opacity: 1;
        }
      }
      .swiper-cover {
        position: absolute;
        width: 100%;
        height: 30%;
        background-color: rgba(0, 0, 0, 0.6);
        bottom: 0%;
        right: 0%;
        z-index: 100;
      }
      .swipercover-top {
        margin-left: 5%;
        margin-right: 5%;
        width: 90%;
        height: 30%;
        color: white;
        border-bottom: 2px solid dodgerblue
      }
      .swipercover-top-text {
        width: 15%;
        height: 100%;
        border-bottom: 2px solid red;
        display: flex;
        align-items: center;
        justify-content: center;
      }
      .swipercover-bottom {
        margin-left: 10%;
        width: 100%;
        height: 70%
      }
    }



相关文章
|
JavaScript
js开发:请解释什么是ES6的类(class),并说明它与传统构造函数的区别。
ES6的类提供了一种更简洁的面向对象编程方式,对比传统的构造函数,具有更好的可读性和可维护性。类使用`class`定义,`constructor`定义构造方法,`extends`实现继承,并可直接定义静态方法。示例展示了如何创建`Person`类、`Student`子类以及它们的方法调用。
221 2
|
移动开发 缓存 JavaScript
2021最新阿里代码规范(前端篇)
2021最新阿里代码规范(前端篇)
57362 11
2021最新阿里代码规范(前端篇)
|
8月前
|
存储 自然语言处理 NoSQL
6.4K star!轻松搞定专业领域大模型推理,这个知识增强框架绝了!
🔥「垂直领域大模型落地难?逻辑推理总出错?这个来自OpenSPG的开源框架,让专业领域知识服务变得像搭积木一样简单!」
420 3
|
监控 安全 数据库
深入探究:GitLab数据备份与还原的高效策略
【10月更文挑战第19天】 在现代软件开发中,GitLab作为一个强大的代码管理和协作平台,其数据备份与还原是保障项目安全和连续性的关键环节。本文将深入探讨GitLab数据备份与还原的高效策略,确保在数据丢失或损坏的情况下,能够快速恢复GitLab实例。
478 2
|
11月前
|
前端开发 小程序
uniapp-实现轮播图效果深度总结【建议收藏】
这是一篇关于前端轮播图实现的详细教程,作者通过多个步骤介绍了如何使用 Vue3 和 Swiper 组件创建一个功能丰富的轮播图。
1107 2
|
机器学习/深度学习 存储 算法
基于Python_opencv人脸录入、识别系统(应用dlib机器学习库)(上)
基于Python_opencv人脸录入、识别系统(应用dlib机器学习库)(上)
332 1
|
JavaScript
解决报错问题:‘ts-node‘ 不是内部或外部命令,也不是可运行的程序或批处理文件。
解决报错问题:‘ts-node‘ 不是内部或外部命令,也不是可运行的程序或批处理文件。
1632 0
|
消息中间件 Java 应用服务中间件
深入理解JVM - 如何排查分区溢出问题
深入理解JVM - 如何排查分区溢出问题
237 0
|
消息中间件 监控 中间件
阿里云中间件有哪些?这里最全面
这其实是一个比较虚的概念。广义的中间件范围很广。起沟通作用的都可以认为是中间件。甚至ODBC这样的东西你也可以认为是中间件。 而阿里云的中间件就比较多了
9770 103