The problem of the layout of WeChat Mini Programs's for cycle

use the for loop block block, roughly as follows:

<block wx:for="{{list}}" wx:key="{{index}}">
    <view id="goods-{{item.gid}}"></view>
    <view class="container-body-box-item"></view>
</block>

I want to loop to get the following arrangement pattern: spaced

    <view id="goods-1"></view>
    <view class="container-body-box-item"></view>
    <view id="goods-2"></view>
    <view class="container-body-box-item"></view>
    <view id="goods-3"></view>
    <view class="container-body-box-item"></view>
   
   

but the actual output looks like this:

    <view class="container-body-box-item"></view>        
    <view class="container-body-box-item"></view>
    <view class="container-body-box-item"></view>
    <view id="goods-1"></view>
    <view id="goods-2"></view>
    <view id="goods-3"></view>
    

how to ask for advice?

Jun.22,2021

Hello, change the code you posted wx:key= "{[index}}" , which should be wx:key= "{{index}}" . You can output the desired results in your own way. The data format of list is as follows:

  

is not possible. The landlord should have written something wrong and didn't find it

.
Menu