使用wx:for()
使用wx:for()
<swiper autoplay="ture" interval="2000" indicator-dots="1" circular="ture" >
<swiper-item wx:for="{{bg}}" wx:key="index">
<image src="{{bg[index]}}" mode="aspectFill"></image>
</swiper-item>
</swiper>
index.js
data: {
bg:[
'../../images/swiper01.jpg',
'../../images/swiper02.jpg',
'../../images/swiper01.jpg'
],
items: ['1', '2', '3',
'4', '5', '6',
'7', '8', '9'
]
}
//未使用items
index.wcss
.container {
display: flex;
justify-content: center;
align-items: center;
}
.box {
display: flex;
flex-direction: column;
align-items: center;
}
.image {
margin-bottom: 10px; /* 根据需要调整上边距 */
}
实现的是小程序wx:for写法