以下是实现交错式瀑布流的简单方式,将盒子分成两部分进行循环来实现交错式显示。
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/348a9f600aff52303d8c75c4ac40bf2d.png#pic_center)
<view class="left-card-container">
<view class="card" wx:for="{{resultData}}" wx:for-item="item" wx:key="articleId" wx:for-index="index" data-id="{{item.articleId}}" wx:if="{{index%2==0}}" bindtap="goArticleDetails">
<view class="square-container">
<view class="square-content" style="background: url({{item.icon}}); background-size: cover;background-repeat: no-repeat;">
</view>
</view>
<view class="title">
{{item.title}}
</view>
</view>
<!-- 更多卡片... -->
</view>
<view class="right-card-container">
<view class="card" wx:for="{{resultData}}" wx:for-item="item" wx:key="articleId" wx:for-index="index" data-id="{{item.articleId}}" wx:if="{{index%2==1}}" bindtap="goArticleDetails">
<view class="square-container">
<view class="square-content" style="background: url({{item.icon}}); background-size: cover;background-repeat: no-repeat;">
</view>
</view>
<view class="title">
{{item.title}}
</view>
</view>
<!-- 更多卡片... -->
</view>