求助 wx:for 能不能循环JSON数据然后得到键、值

发布于 6 年前作者 jing162324 次浏览最后编辑 6 年前来自 ask

如下图这样:

2 回复
juanguo
juanguo1 楼6 年前

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

tao91
tao912 楼5 年前

可以,如:

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>