说明:通过http请求从后台拿到一个userInfo的JSON对象,打印,可以看到userInfo.playWithUsers[0].playWithUsers这个属性是有值的。但是单独打印userInfo.playWithUsers[0].playWithUsers,结果却是null。并且,在AppData中userInfo.playWithUsers[0].playWithUsers这个属性已经有值了,说明数据成功渲染了,但是在二重循环中却拿不到值。
js代码:
console.log(userInfo)
console.log(userInfo.playWithUsers[0].playWithUsers)
this.setData({
userInfo,
})
wxml代码:
<block wx:for="{{userInfo.playWithUsers}}" wx:key="{{index}}" wx:for-item="user">
{{user.name}}
<block wx:for="{{user.playWithUsers}}" wx:key="{{index}}" >
{{item.name}}
</block>
</block>