<view wx:for="{{items}}" wx:for-index="index" wx:for-item="item"> {{index+1}}、{{item.title}} </view>
核心代碼就是 wx:for,對應一個數組。
而 wx:for-index 指明后面如果要用數組索引的話,用什么名字,如果名字是 index,則可省略,直接使用。
而 wx:for-item 指明后面如果要用數組索引對應的項的話,用什么名字,如果名字是 item,則可省略,直接使用。
.js 代碼
Page({ data: { items: [ { "url":"http://127.0.0.1/1.flv", "title":"這是標題一" }, { "url":"http://127.0.0.1/2.flv", "title":"這是標題二" } ] } })
原文地址: http://blog.csdn.net/yelin042/article/details/72518977