先赞后看,此生必赚!
wxml:
使用wx:for之后,需要加入wx:key='{{index}}'来指定下标
如:
<view wx:for='{{list}}' wx:key='{{index}}'>
姓名:{{item.name}},年龄:{{item.age}}
</view>
js:
pageData.forEach(function(item, index){
console.log(item); //这里的item就是从数组里拿出来的每一个每一组
that.setData({
id: item.id,
title: item.title
})
})
体验小程序
更多内容,请关注公众号:程序员高手之路
在公众号回复:小程序资源 即可免费获取以下微信小程序视频教程!