微信小程序如何使用swiper组件实现图片轮播切换显示功能
更新:HHH   时间:2023-1-7


这篇文章将为大家详细讲解有关微信小程序如何使用swiper组件实现图片轮播切换显示功能,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。

具体如下:

1、效果展示

2、关键代码

index.wxml:

<swiper indicator-dots="true"autoplay="true" interval="3000" duration="600" >
 <swiper-item>
 <image src="../../pages/images/img1.png" />
 </swiper-item>
 <swiper-item>
 <image src="../../pages/images/img2.png" />
 </swiper-item>
 <swiper-item>
 <image src="../../pages/images/img3.png" />
 </swiper-item>
</swiper>

swiper组件属性说明如下:

属性名类型默认值说明最低版本
indicator-dotsBooleanfalse是否显示面板指示点
indicator-colorColorrgba(0, 0, 0, .3)指示点颜色1.1.0
indicator-active-colorColor#000000当前选中的指示点颜色1.1.0
autoplayBooleanfalse是否自动切换
currentNumber0当前所在页面的 index
intervalNumber5000自动切换时间间隔
durationNumber500滑动动画时长
circularBooleanfalse是否采用衔接滑动
verticalBooleanfalse滑动方向是否为纵向
bindchangeEventHandle
current 改变时会触发 change 事件,event.detail = {current: current, source: source}

关于“微信小程序如何使用swiper组件实现图片轮播切换显示功能”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。

返回web开发教程...