block wxfor=images wxkey=index view wxif=index 3 class=image-container view class=flex-item image class=photo src=item mode=aspectFillimage
你可以按照以下方式修改代码,以实现每行显示三个照片的效果:
<block wx:for="{{images}}" wx:key="index" wx:for-item="item" wx:for-index="index">
<view wx:if="{{index % 3 === 0}}" class="image-container">
<view class="flex-item">
<image class="photo" src="{{item}}" mode="aspectFill"></image>
</view>
<view class="flex-item">
<button class="delete-btn" data-index="{{index}}" bindtap="deleteImage" type="primary" size="mini">删除</button>
</view>
</view>
</block>
这样,每当 index 的值是3的倍数时,就会创建一个新的 image-container 容器,并在其中显示一行的三个照片
原文地址: https://www.cveoy.top/t/topic/ioGU 著作权归作者所有。请勿转载和采集!