一个小轮播图

简介: 一个小轮播图

用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%
      }
    }



目录
打赏
0
0
0
0
1
分享
相关文章
js开发:请解释什么是ES6的类(class),并说明它与传统构造函数的区别。
ES6的类提供了一种更简洁的面向对象编程方式,对比传统的构造函数,具有更好的可读性和可维护性。类使用`class`定义,`constructor`定义构造方法,`extends`实现继承,并可直接定义静态方法。示例展示了如何创建`Person`类、`Student`子类以及它们的方法调用。
159 2
6.4K star!轻松搞定专业领域大模型推理,这个知识增强框架绝了!
🔥「垂直领域大模型落地难?逻辑推理总出错?这个来自OpenSPG的开源框架,让专业领域知识服务变得像搭积木一样简单!」
128 3
深入探究:GitLab数据备份与还原的高效策略
【10月更文挑战第19天】 在现代软件开发中,GitLab作为一个强大的代码管理和协作平台,其数据备份与还原是保障项目安全和连续性的关键环节。本文将深入探讨GitLab数据备份与还原的高效策略,确保在数据丢失或损坏的情况下,能够快速恢复GitLab实例。
293 2
探索深度学习在图像识别中的应用与挑战
本文深入探讨了深度学习技术在图像识别领域的应用,分析了其背后的原理、当前的成就以及面临的主要挑战。通过具体案例分析,揭示了深度学习模型如何从复杂的图像数据中学习到有效的特征表示,以及这些技术进步如何推动计算机视觉领域的发展。同时,文章也讨论了深度学习模型训练过程中的数据依赖性、过拟合问题、计算资源需求等挑战,并提出了未来研究的可能方向。
146 30
uniapp-实现轮播图效果深度总结【建议收藏】
这是一篇关于前端轮播图实现的详细教程,作者通过多个步骤介绍了如何使用 Vue3 和 Swiper 组件创建一个功能丰富的轮播图。
344 2
如何在现有的 JavaScript 项目中渐进式地采用 TypeScript
【6月更文挑战第13天】TypeScript,JavaScript的超集,引入静态类型和更多特性,提升代码安全性和可读性。在JavaScript项目中渐进式采用TypeScript可从新模块开始,逐步转换代码,编写.d.ts文件支持第三方库,配置编译选项,并编写测试用例。通过监控和评估,改善项目质量和效率。大型项目尤其受益于TypeScript的类型安全、社区支持和工具兼容性。
123 3
基于Python_opencv人脸录入、识别系统(应用dlib机器学习库)(上)
基于Python_opencv人脸录入、识别系统(应用dlib机器学习库)(上)
181 1
寻找未来之星!6000+队伍,13大开源社区,“通义灵码贡献开源”大赛等你来
“2024天池云原生编程挑战赛-赛道3:用通义灵码,人人都是开源贡献者”大赛持续进行中,通义灵码助你快速上手开源项目,参与 2024 天池云原生编程挑战赛-通义灵码赛道,每个赛道5000元大奖和优先提交精美礼品等你领,还有开源社区多位明星专家现身答疑支持。
阿里云广东分公司合作伙伴新人营圆满举行,“伙伴优先”态度明确
2023年1月10日,阿里云广东分公司合作伙伴新人营在广东深圳圆满举行,包括深圳法本信息、广州三维睿新、广东亿网通、深圳慧梧科技、广州贝讯等30余家新加入的合作伙伴参与了此次新人营。
AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等

登录插画

登录以查看您的控制台资源

管理云资源
状态一览
快捷访问