### page頁面生命周期
**生命周期函數**
* `onLoad`: 頁面加載
一個頁面只會調用一次,可以在 onLoad 中獲取打開當前頁面所調用的 query 參數。
* `onShow`: 頁面顯示
每次打開頁面都會調用一次。
* `onReady`: 頁面初次渲染完成
一個頁面只會調用一次,代表頁面已經準備妥當,可以和視圖層進行交互。
對界面的設置如wx.setNavigationBarTitle請在onReady之后設置。
* ` onHide`: 頁面隱藏
當navigateTo或底部tab切換時調用。
* ` onUnload`: 頁面卸載
當redirectTo或navigateBack的時候調用。
> 通過打斷點說明生命周期的順序。

### 數據綁定
` post.js`
~~~javascript
data: {
date:"Nov 07 1992",
title:"正是蝦肥蟹壯時"
},
/**
* 生命周期函數--監聽頁面加載
*/
onLoad: function (options) {
console.log('load');
var post_content1 = {
date: "Sep 18 2016",
title: "正是蝦肥蟹壯時",
img:{
imgSrc: "/images/post/crab.png",
avatar: "/images/avatar/1.png"
},
content: "菊黃蟹正肥,品嘗秋之味。徐志摩把,“看初花的荻蘆”和“到樓外樓吃蟹”,并列為秋天來杭州不能錯過的風雅之事;用林妹妹的話講是“螯封嫩玉雙雙滿,",
reading: "112",
collection: "96",
author: "林白衣",
}
this.setData(post_content1);
},
~~~
~~~html
<view class="post-container">
<view class="post-author-date">
<image class="post-author" src="{{img.avatar}}"></image>
<text class="post-date">{{date}}</text>
</view>
<text class='post-title'>{{title}}</text>
<image class="post-image" src="{{img.imgSrc}}"></image>
<text class="post-content">{{content}}</text>
<view class='post-like'>
<image class='post-like-image' src="../../images/icon/chat.png"></image>
<text class='post-like-font'>{{collection}}</text>
<image class='post-like-image' src="../../images/icon/view.png"></image>
<text class='post-like-font'>{{reading}}</text>
</view>
~~~