
index.wxml:
<swiper indicator-dots="true" autoplay="true" interval="3000" duration="800" circular="true">
<block wx:for="{{imgUrls}}">
<swiper-item>
<image src="{{item}}" class="slide-image" />
</swiper-item>
</block>
</swiper>
index.js:
Page({
data:{
imgUrls: [
'/assets/images/spouseR/7.png',
'/assets/images/spouseW/19.png',
'/assets/images/spouseW/1.png',
'/assets/images/spouseW/28.png',
'/assets/images/spouseW/11.png',
'/assets/images/spouseW/33.png'
],
}
})
index.wxss:
swiper{
width: 100vw;
height: 40vh;
}
swiper-item {
width: 100vw;
height: 100%;
}
image {
height: 100%;
width: 100%;
}
该博客展示了如何在微信小程序中实现一个自动轮播的图片滑动效果,使用了`swiper`组件和`wx:for`指令来遍历图片数组。样式设置确保了滑动的无缝循环和图片的全屏展示。
1734

被折叠的 条评论
为什么被折叠?



