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

相关文章

C++中零拷贝的多种实现方式

《C++中零拷贝的多种实现方式》本文主要介绍了C++中零拷贝的实现示例,旨在在减少数据在内存中的不必要复制,从而提高程序性能、降低内存使用并减少CPU消耗,零拷贝技术通过多种方式实现,下面就来了解一下... 目录一、C++中零拷贝技术的核心概念二、std::string_view 简介三、std::stri

C++高效内存池实现减少动态分配开销的解决方案

《C++高效内存池实现减少动态分配开销的解决方案》C++动态内存分配存在系统调用开销、碎片化和锁竞争等性能问题,内存池通过预分配、分块管理和缓存复用解决这些问题,下面就来了解一下... 目录一、C++内存分配的性能挑战二、内存池技术的核心原理三、主流内存池实现:TCMalloc与Jemalloc1. TCM

OpenCV实现实时颜色检测的示例

《OpenCV实现实时颜色检测的示例》本文主要介绍了OpenCV实现实时颜色检测的示例,通过HSV色彩空间转换和色调范围判断实现红黄绿蓝颜色检测,包含视频捕捉、区域标记、颜色分析等功能,具有一定的参考... 目录一、引言二、系统概述三、代码解析1. 导入库2. 颜色识别函数3. 主程序循环四、HSV色彩空间

全面解析HTML5中Checkbox标签

《全面解析HTML5中Checkbox标签》Checkbox是HTML5中非常重要的表单元素之一,通过合理使用其属性和样式自定义方法,可以为用户提供丰富多样的交互体验,这篇文章给大家介绍HTML5中C... 在html5中,Checkbox(复选框)是一种常用的表单元素,允许用户在一组选项中选择多个项目。本

HTML5 搜索框Search Box详解

《HTML5搜索框SearchBox详解》HTML5的搜索框是一个强大的工具,能够有效提升用户体验,通过结合自动补全功能和适当的样式,可以创建出既美观又实用的搜索界面,这篇文章给大家介绍HTML5... html5 搜索框(Search Box)详解搜索框是一个用于输入查询内容的控件,通常用于网站或应用程

Python实现精准提取 PDF中的文本,表格与图片

《Python实现精准提取PDF中的文本,表格与图片》在实际的系统开发中,处理PDF文件不仅限于读取整页文本,还有提取文档中的表格数据,图片或特定区域的内容,下面我们来看看如何使用Python实... 目录安装 python 库提取 PDF 文本内容:获取整页文本与指定区域内容获取页面上的所有文本内容获取

基于Python实现一个Windows Tree命令工具

《基于Python实现一个WindowsTree命令工具》今天想要在Windows平台的CMD命令终端窗口中使用像Linux下的tree命令,打印一下目录结构层级树,然而还真有tree命令,但是发现... 目录引言实现代码使用说明可用选项示例用法功能特点添加到环境变量方法一:创建批处理文件并添加到PATH1

Java使用HttpClient实现图片下载与本地保存功能

《Java使用HttpClient实现图片下载与本地保存功能》在当今数字化时代,网络资源的获取与处理已成为软件开发中的常见需求,其中,图片作为网络上最常见的资源之一,其下载与保存功能在许多应用场景中都... 目录引言一、Apache HttpClient简介二、技术栈与环境准备三、实现图片下载与保存功能1.

canal实现mysql数据同步的详细过程

《canal实现mysql数据同步的详细过程》:本文主要介绍canal实现mysql数据同步的详细过程,本文通过实例图文相结合给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的... 目录1、canal下载2、mysql同步用户创建和授权3、canal admin安装和启动4、canal

CSS3中的字体及相关属性详解

《CSS3中的字体及相关属性详解》:本文主要介绍了CSS3中的字体及相关属性,详细内容请阅读本文,希望能对你有所帮助... 字体网页字体的三个来源:用户机器上安装的字体,放心使用。保存在第三方网站上的字体,例如Typekit和Google,可以link标签链接到你的页面上。保存在你自己Web服务器上的字