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

 效果:

原文地址: https://www.lllomh.com/article/details?id=135838963 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/447904.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【代码随想录20】669.修剪二叉搜索树 108.将有序数组转换为二叉搜索树 538.把二叉搜索树转换为累加树

目录 669.修剪二叉搜索树题目描述参考代码 108.将有序数组转换为二叉搜索树题目介绍参考代码 538.把二叉搜索树转换为累加树题目描述参考代码 669.修剪二叉搜索树 题目描述 给你二叉搜索树的根节点 root &#xff0c;同时给定最小边界low 和最大边界 high。通过修剪二叉搜索树…

XGB-1:XGBoost安装及快速上手

XGBoost是“Extreme Gradient Boosting”的缩写&#xff0c;是一种高效的机器学习算法&#xff0c;用于分类、回归和排序问题。它由陈天奇&#xff08;Tianqi Chen&#xff09;在2014年首次提出&#xff0c;并迅速在数据科学竞赛和工业界获得广泛应用。XGBoost基于梯度提升框架…

【Git】01 Git介绍与安装

文章目录 一、版本控制系统二、Git三、Windows安装Git3.1 下载Git3.2 安装3.3 检查 四、Linux安装Git4.1 YUM安装4.2 源码安装 五、配置Git5.1 配置用户名和邮箱5.2 配置级别5.3 查看配置 六、总结 一、版本控制系统 版本控制系统&#xff0c;Version Control System&#xff…

Unity中AssetBundle的打包和分包策略

在Unity中&#xff0c;AssetBundle的打包策略主要是针对资源的整理和分组&#xff0c;以做到即方便管理&#xff0c;又能有效优化资源的加载和内存使用。具体来看包括以下几种常见的策略&#xff1a; 打包资源的预处理&#xff1a;为了减小AssetBundle的大小和数量&#xff0c;…

C语言数据结构之两道OJ题带你走近环形链表

倘若南风知我意 莫将晚霞落黄昏 &#x1f3a5;烟雨长虹&#xff0c;孤鹜齐飞的个人主页 &#x1f525;个人专栏 &#x1f3a5;前期回顾-单链表 目录 环形链表 题目描述# 思路# 代码测试# 环形链表II 题目描述# 思路# 代码测试# 环形链表 题目链接&#xff1a;环形链表 题目…

基于极大似然法和最小二乘法系统参数辨识matlab仿真,包含GUI界面

目录 1.程序功能描述 2.测试软件版本以及运行结果展示 3.核心程序 4.本算法原理 1.极大似然法系统参数辨识 2. 最小二乘法系统参数辨识 5.完整程序 1.程序功能描述 分别对比基于极大似然法的系统参数辨识以及基于最小二乘法的系统参数辨识&#xff0c;输出起参数辨识收敛…

linux中vim的操作

(码字不易&#xff0c;关注一下吧w~~w) 命令模式&#xff1a; 当我们按下esc键时&#xff0c;我们会进入命令模式&#xff1b;当使用vi打开一个文件时也是进入命令模式。 光标移动&#xff1a; 1 保存退出&#xff1a;ZZ 2 代码格式化&#xff1a;ggG 3 光标移动&#xff…

(学习日记)2024.02.01:引用变量 / 默认实参 / 一元作用域运算符 / 函数重载

写在前面&#xff1a; 由于时间的不足与学习的碎片化&#xff0c;写博客变得有些奢侈。 但是对于记录学习&#xff08;忘了以后能快速复习&#xff09;的渴望一天天变得强烈。 既然如此 不如以天为单位&#xff0c;以时间为顺序&#xff0c;仅仅将博客当做一个知识学习的目录&a…

Linux一键部署telegraf 实现Grafana Linux 图形展示

influxd2前言 influxd2 是 InfluxDB 2.x 版本的后台进程,是一个开源的时序数据库平台,用于存储、查询和可视化时间序列数据。它提供了一个强大的查询语言和 API,可以快速而轻松地处理大量的高性能时序数据。 telegraf 是一个开源的代理程序,它可以收集、处理和传输各种不…

三.Linux权限管控 1-5.Linux的root用户用户和用户组查看权限控制信息chmod命令chown命令

目录 三.Linux权限管控 1.Linux的root用户 root用户&#xff08;超级管理员&#xff09; su和exit命令 sudo命令 为普通用户配置sudo认证 三.Linux权限管控 2.用户和用户组 用户&#xff0c;用户组 用户组管理 用户管理 getent---查看系统中的用户 三.Linux权限管控…

【2024美赛】F题(中英文):减少非法野生动物贸易Problem F: Reducing Illegal Wildlife Trade

【2024美赛】F题&#xff08;中英文&#xff09;&#xff1a;减少非法野生动物贸易Problem F: Reducing Illegal Wildlife Trade 写在最前面2024美赛翻译 —— 跳转链接 中文赛题问题F&#xff1a;减少非法野生动物贸易你的工作应探讨以下子问题&#xff1a;参考文献词汇表 英文…

XGB-2: Boosted Trees(提升树)简介

XGBoost代表“Extreme Gradient Boosting”&#xff0c;其中术语“Gradient Boosting”来源于Friedman的论文《Greedy Function Approximation: A Gradient Boosting Machine》。 梯度提升树已经存在一段时间&#xff0c;关于这个主题有很多资料。本部分将使用监督学习的元素&…