在微信小程序中通过wx:for来渲染列表
具体案例如下
1、index.js中的data中写一组数据
todos:[
{name:'JavaScript',completed:false},
{ name: 'html',completed: true },
{name:'css',completed:false}
]
2、index.wxml中渲染
<view wx:for="{{todos}}">
<checkbox checked="{{item.completed}}"></checkbox>
<text>{{ item.name }}</text>
</view>
注意:如果全局属性中有item关键词,可以使用wx:for-item去给当前遍历的序号起别名