### `block wx:for`
可以将 wx:for 用在<block/>标签上,以渲染一个包含多节点的结构块。例如:
~~~html
<block wx:for="{{[1, 2, 3]}}">
<view> {{index}}: </view>
<view> {{item}} </view>
</block>
~~~
* 使用 wx:for-item 可以指定数组当前元素的变量名
* 使用 wx:for-index 可以指定数组当前下标的变量名
### 改写新闻页
~~~html
<block wx:for="{{posts_key}}" wx:for-index="ids">
<view class="post-container" >
<view class="post-author-date">
<image class="post-author" src="{{item.avatar}}"></image>
<text class="post-date">{{item.date}}</text>
</view>
<text class='post-title'>{{item.title}}</text>
<image class="post-image" src="{{item.imgSrc}}"></image>
<text class="post-content">{{item.content}}</text>
<view class='post-like'>
<image class='post-like-image' src="../../images/icon/chat.png"></image>
<text class='post-like-font'>{{item.collection}}</text>
<image class='post-like-image' src="../../images/icon/view.png"></image>
<text class='post-like-font'>{{item.reading}}</text>
</view>
</view>
</block>
~~~
~~~javascript
onLoad: function (options) {
console.log('load');
var posts_content=[
{
date: "Sep 18 2016",
title: "正是虾肥蟹壮时",
imgSrc: "/images/post/crab.png",
avatar: "/images/avatar/1.png",
content: "菊黄蟹正肥,品尝秋之味。徐志摩把,“看初花的荻芦”和“到楼外楼吃蟹”,并列为秋天来杭州不能错过的风雅之事;用林妹妹的话讲是“螯封嫩玉双双满,",
reading: "112",
collection: "96",
author: "林白衣",
}, {
date: "Nov 20 2016",
title: "比利·林恩的中场故事",
content: "一 “李安是一位绝不会重复自己的导演,本片将极富原创性李安众所瞩目的新片《比利林恩漫长的中场休息》,正式更名《半场无战事》。",
imgSrc: "/images/post/bl.png",
reading: 62,
collection: 92,
author: "迷的城",
avatar: "/images/avatar/1.png"
}
]
this.setData({
posts_key:posts_content
});
},
~~~