求助 wx:for 能不能循环JSON数据然后得到键、值
发布于 5 年前 作者 jing16 2146 次浏览 来自 问答

如下图这样:

2 回复

这种数据格式 不是我想要的

可以,如:

json结构(对象数组):

item: {

images:

[{ “src”: “xxxxxx”, “iscover”: false },

{ “src”: “xxxxxx”, “iscover”: false },

{ “src”: “xxxxxx”, “iscover”: true },

{ “src”: “xxxxxx”, “iscover”: false }]

}

<!-- 显示封面图片 -->

<block wx:for="{{item.images}}" wx:for-item=“image” wx:key="{{index}}">

<block wx:if="{{image.iscover}}">

<image src=’{{image.src}}’ mode=“aspectFill”></image>

</block>

</block>

回到顶部