swiper

html

<div class="banner">
			<div class="swiper-container banner-imp" style="height: 2rem;">
				<div class="swiper-wrapper" onclick="showMosk3()">
					<div class="swiper-slide" title="前车轮胎" data-index="0">
						<img src="" alt="" class="oneimg">
					</div>
					<div class="swiper-slide" title="前车轮胎2" data-index="1">
						<img src="" alt="" class="twoimg">
					</div>
					<div class="swiper-slide" title="前车轮胎3" data-index="2">
						<img src="" alt="" class="thrimg">
					</div>
					<div class="swiper-slide" title="前车轮胎4" data-index="3">
						<img src="" alt="" class="fouimg">
					</div>
					<div class="swiper-slide" title="前车轮胎5" data-index="4"> 
						<img src="" alt="" class="fivimg">
					</div>
					<div class="swiper-slide" title="前车轮胎6" data-index="5">
						<img src="" alt="" class="siximg">
					</div>
					<div class="swiper-slide" title="前车轮胎7" data-index="6">
						<img src="" alt="" class="sevimg">
					</div>
					<div class="swiper-slide" title="前车轮胎8" data-index="7">
						<img src="" alt="" class="aigimg">
					</div>
					<div class="swiper-slide" title="前车轮胎9" data-index="8">
						<img src="" alt="" class="nigimg">
					</div>
					<div class="swiper-slide" title="前车轮胎10" data-index="9">
						<img src="" alt="" class="tenimg">
					</div>
				</div>
			</div>
		</div>
//普通轮播 js
var mySwiper = new Swiper('.banner-imp', {
				// pagination : ".banner .swiper-pagination",
				direction: 'horizontal', // 水平切换选项
				// autoplay: {
				// 	disableOnInteraction: false //是否轮播
				// },
				// loop: true, // 无缝循环 默认为false
				grabCursor: true,
				observer: true, //swiper自己或子元素变化时,自动初始化swiper //重点,一点要放
				observeParents: true //swiper的父元素变化时,自动初始化swiper //重点,一点要放
			})
// 进阶轮播
<div class="swiper-container gallery-top">
				<div class="swiper-wrapper">
					<div class="swiper-slide" title="前车轮胎" >
						<img src="" alt="" class="oneimg">
					</div>
					<div class="swiper-slide" title="前车轮胎2">
						<img src="" alt="" class="twoimg">
					</div>
					<div class="swiper-slide" title="前车轮胎3">
						<img src="" alt="" class="thrimg">
					</div>
					<div class="swiper-slide" title="前车轮胎4">
						<img src="" alt="" class="fouimg">
					</div>
					<div class="swiper-slide" title="前车轮胎5">
						<img src="" alt="" class="fivimg">
					</div>
					<div class="swiper-slide" title="前车轮胎6">
						<img src="" alt="" class="siximg">
					</div>
					<div class="swiper-slide" title="前车轮胎7">
						<img src="" alt="" class="sevimg">
					</div>
					<div class="swiper-slide" title="前车轮胎8">
						<img src="" alt="" class="aigimg">
					</div>
					<div class="swiper-slide" title="前车轮胎9">
						<img src="" alt="" class="nigimg">
					</div>
					<div class="swiper-slide" title="前车轮胎10">
						<img src="" alt="" class="tenimg">
					</div>
				</div>
			</div>
			<p class="car"></p>
			<!-- Add Pagination -->
			<span class="swiper-pagination"></span>
			<div class="swiper-container gallery-thumbs">
				<div class="swiper-wrapper">
					<div class="swiper-slide" title="前车轮胎">
						<img src="" alt="" class="oneimg">
					</div>
					<div class="swiper-slide" title="前车轮胎2">
						<img src="" alt="" class="twoimg">
					</div>
					<div class="swiper-slide" title="前车轮胎3">
						<img src="" alt="" class="thrimg">
					</div>
					<div class="swiper-slide" title="前车轮胎4">
						<img src="" alt="" class="fouimg">
					</div>
					<div class="swiper-slide" title="前车轮胎">
						<img src="" alt="" class="fivimg">
					</div>
					<div class="swiper-slide" title="前车轮胎">
						<img src="" alt="" class="siximg">
					</div>
					<div class="swiper-slide" title="前车轮胎">
						<img src="" alt="" class="sevimg">
					</div>
					<div class="swiper-slide" title="前车轮胎">
						<img src="" alt="" class="aigimg">
					</div>
					<div class="swiper-slide" title="前车轮胎">
						<img src="" alt="" class="nigimg">
					</div>
					<div class="swiper-slide" title="前车轮胎">
						<img src="" alt="" class="tenimg">
					</div>
				</div>
			</div>
			//车易拍查看大图。左右滑动实时切换title,显示位于第几张图片.
			setInterval(function() {
					var index; //全局变量
					$('.car').html($('.gallery-top .swiper-wrapper .swiper-slide-active').attr('title'));
							}, 1000)
							$('.banner-imp .swiper-wrapper .swiper-slide').on('click',function(){
								index = $(this).attr('data-index')
								var galleryThumbs = new Swiper('.gallery-thumbs', {
									
									initialSlide :index,//从第几张图显示
									spaceBetween: 10,
									slidesPerView: 4,
									freeMode: true,
									watchSlidesVisibility: true,
									watchSlidesProgress: true,
									observer: true, //swiper自己或子元素变化时,自动初始化swiper
									observeParents: true //swiper的父元素变化时,自动初始化swiper
								});
								var galleryTop = new Swiper('.gallery-top', {
									// 1/10张图 显示目前位于第几张图
									pagination: {
									  el: '.swiper-pagination',
									  type: 'fraction',
									},
									initialSlide :index,//从第几张图显示
									// pagination: "#loadingBg3 .swiper-pagination",
									spaceBetween: 10,
									thumbs: {
										swiper: galleryThumbs
									},
									grabCursor: true,
									observer: true, //swiper自己或子元素变化时,自动初始化swiper
									observeParents: true //swiper的父元素变化时,自动初始化swiper
								});
							})
PS:一个页面使用多个swiper插件, new Swiper('.gallery-top')这里自定义class用来区分swiper作用域
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值