生命周期
Vue實(shí)例運(yùn)行的整個(gè)流程
http://cn.vuejs.org/v2/guide/instance.html#search-query-sidebar

image
beforeCreate
創(chuàng)建之前
created
創(chuàng)建之后
created () { // 發(fā)起網(wǎng)絡(luò)請(qǐng)求
console.log('created');
}
beforeMount
渲染完成之前
mounted
渲染完成之后
mounted () { // 頁(yè)面渲染完成
console.log('mounted');
}
beforeUpdate
更新之前
updated
更新之后
beforeDestroy
釋放之前
destroyed
釋放之后
代碼示例:
beforeCreate () {
console.log('beforeCreate');
},
created () {
console.log('created');
},
beforeMount () {
console.log('beforeMount');
},
mounted () {
console.log('mounted');
},
beforeUpdate () {
console.log('beforeUpdate');
},
updated () {
console.log('updated');
},
beforeDestroy () { // 調(diào)用$destroy()方法便會(huì)執(zhí)行
console.log('beforeDestroy');
},
destroyed () {
console.log('destroyed');
}