vue实现带缩略图的轮播图(vue-awesome-swiper)

2024-02-01 07:44

本文主要是介绍vue实现带缩略图的轮播图(vue-awesome-swiper),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

demo 请复制打开  https://download.lllomh.com/cliect/#/product/E125504451206525

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 --><swiperclass="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><divclass="swiper-button-next swiper-button-white"slot="button-next"></div><divclass="swiper-button-prev swiper-button-white"slot="button-prev"></div></swiper><!-- swiper2 Thumbs --><swiperclass="swiper gallery-thumbs":options="swiperOptionThumbs"ref="swiperThumbs"><swiper-slideclass="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() {// 实现swiper双向控制this.$nextTick(() => {const swiperTop = this.$refs.swiperTop.swiperconst swiperThumbs = this.$refs.swiperThumbs.swiperswiperTop.controller.control = swiperThumbsswiperThumbs.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 samespaceBetween: 10,observer: true, //修改swiper自己或子元素时,自动初始化swiperobserveParents: 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 samespaceBetween: 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>

这样就可以了,demo 例子:  Integrated shopping mallicon-default.png?t=N7T8https://download.lllomh.com/cliect/#/product/E125504451206525

 效果:

这篇关于vue实现带缩略图的轮播图(vue-awesome-swiper)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/666558

相关文章

Spring Security+JWT如何实现前后端分离权限控制

《SpringSecurity+JWT如何实现前后端分离权限控制》本篇将手把手教你用SpringSecurity+JWT搭建一套完整的登录认证与权限控制体系,具有很好的参考价值,希望对大家... 目录Spring Security+JWT实现前后端分离权限控制实战一、为什么要用 JWT?二、JWT 基本结构

Java实现优雅日期处理的方案详解

《Java实现优雅日期处理的方案详解》在我们的日常工作中,需要经常处理各种格式,各种类似的的日期或者时间,下面我们就来看看如何使用java处理这样的日期问题吧,感兴趣的小伙伴可以跟随小编一起学习一下... 目录前言一、日期的坑1.1 日期格式化陷阱1.2 时区转换二、优雅方案的进阶之路2.1 线程安全重构2

Android实现两台手机屏幕共享和远程控制功能

《Android实现两台手机屏幕共享和远程控制功能》在远程协助、在线教学、技术支持等多种场景下,实时获得另一部移动设备的屏幕画面,并对其进行操作,具有极高的应用价值,本项目旨在实现两台Android手... 目录一、项目概述二、相关知识2.1 MediaProjection API2.2 Socket 网络

使用Python实现图像LBP特征提取的操作方法

《使用Python实现图像LBP特征提取的操作方法》LBP特征叫做局部二值模式,常用于纹理特征提取,并在纹理分类中具有较强的区分能力,本文给大家介绍了如何使用Python实现图像LBP特征提取的操作方... 目录一、LBP特征介绍二、LBP特征描述三、一些改进版本的LBP1.圆形LBP算子2.旋转不变的LB

Redis消息队列实现异步秒杀功能

《Redis消息队列实现异步秒杀功能》在高并发场景下,为了提高秒杀业务的性能,可将部分工作交给Redis处理,并通过异步方式执行,Redis提供了多种数据结构来实现消息队列,总结三种,本文详细介绍Re... 目录1 Redis消息队列1.1 List 结构1.2 Pub/Sub 模式1.3 Stream 结

C# Where 泛型约束的实现

《C#Where泛型约束的实现》本文主要介绍了C#Where泛型约束的实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧... 目录使用的对象约束分类where T : structwhere T : classwhere T : ne

将Java程序打包成EXE文件的实现方式

《将Java程序打包成EXE文件的实现方式》:本文主要介绍将Java程序打包成EXE文件的实现方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录如何将Java程序编程打包成EXE文件1.准备Java程序2.生成JAR包3.选择并安装打包工具4.配置Launch4

HTML5中的Microdata与历史记录管理详解

《HTML5中的Microdata与历史记录管理详解》Microdata作为HTML5新增的一个特性,它允许开发者在HTML文档中添加更多的语义信息,以便于搜索引擎和浏览器更好地理解页面内容,本文将探... 目录html5中的Mijscrodata与历史记录管理背景简介html5中的Microdata使用M

html5的响应式布局的方法示例详解

《html5的响应式布局的方法示例详解》:本文主要介绍了HTML5中使用媒体查询和Flexbox进行响应式布局的方法,简要介绍了CSSGrid布局的基础知识和如何实现自动换行的网格布局,详细内容请阅读本文,希望能对你有所帮助... 一 使用媒体查询响应式布局        使用的参数@media这是常用的

HTML5表格语法格式详解

《HTML5表格语法格式详解》在HTML语法中,表格主要通过table、tr和td3个标签构成,本文通过实例代码讲解HTML5表格语法格式,感兴趣的朋友一起看看吧... 目录一、表格1.表格语法格式2.表格属性 3.例子二、不规则表格1.跨行2.跨列3.例子一、表格在html语法中,表格主要通过< tab