当前位置:网站首页>swiper组件封装
swiper组件封装
2022-04-23 05:56:00 【画不完的饼】
swiper组件
<!--组件调用-->
<ui-swipe :product-image="swiperList" :img-event="showImageViewer" key-name="imageUrl"></ui-swipe>
<!--组件内容-->
<template>
<div class="swipe" @click="imgEvent" style="visibility: 'visible' !important">
<div class="swipe-wrap">
<div class="swiper-container">
<div class="swiper-wrapper">
<figure class="swiper-slide" v-for="(pic, picIndex) in productImage" :key="picIndex" >
<template v-if="pic.linkUrl">
<a :href="pic.linkUrl || 'javascript:void(0)'">
<img
class="h100per"
alt="pic"
:src="pic[keyName]?pic[keyName]:defaultPic"
style="visibility: 'visible' !important"
/>
</a>
</template>
<template v-if="!pic.linkUrl">
<img
class="h100per"
alt="pic"
:src="pic[keyName]?pic[keyName]:defaultPic"
style="visibility: 'visible' !important"
/>
</template>
</figure>
</div>
<div class="swiper-pagination swiper-pagination-red"></div>
</div>
</div>
<slot></slot>
</div>
</template>
<script>
export default {
props: ['productImage', 'imgEvent', 'keyName', 'defaultPic'],
mounted() {
var that = this
Vue.nextTick(function() {
setTimeout(() => {
// eslint-disable-next-line no-undef
new Swiper('.swiper-container', {
autoplay: {
// 自动播放
delay: 3000, // 3s
stopOnLast: false, // 最后一帧自动播放
disableOnInteraction: false // 手动滑动后也能正常播放
},
loop: that.productImage.length > 1, // 回滚
pagination: {
// 配置小点
el: '.swiper-pagination',
clickable: true
}
})
}, 200)
})
},
methods: {}
}
</script>
版权声明
本文为[画不完的饼]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_39162041/article/details/108885019
边栏推荐
猜你喜欢
随机推荐
写一个正则
百度地图案例-修改地图样式
深入理解控制反转和依赖注入
el-date-picker限制选择范围,从当前时间到两个月前
自用学习笔记-connectingString配置
freeCodeCamp----prob_calculator练习
Analysis and setting of dead time
JS中 t, _ => 的解析
查漏补缺(二)
WebSocket(基础)
uniapp 自定义搜索框适配小程序对齐胶囊
Oracle改成mysql
.NET Standard详解
Set与Map
获取当前一周的时间范围
导入文件时候 new FormData()
Navicat 连接 oracle library is not loaded的解决方法
JS中的this指向
Node访问服务器端静态资源
手动实现简单的Promise及其基础功能