1,vue的生命周期图

2,生命周期的方法
3,生命周期测试代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="vue.js"></script>
</head>
<body>
<div id="app">{{content}}</div>
<script>
var app=new Vue({
el:"#app",
data:{
content:'hello vue'
},
beforeCreate:function () {
console.log("beforeCreate")
},
created:function () {
console.log("created")
},
beforeMount:function () {
console.log("beforeMount")
},
mounted:function () {
console.log("mounted")
},
beforeUpdate:function () {
console.log("beforeUpdate")
},
updated:function () {
console.log("updated")
},
beforeDestroy:function () {
console.log("beforeDestroy")
},
destroyed:function () {
console.log("destroyed")
}
})
</script>
</body>
</html> |
在浏览器中操作:
页面渲染的时候回执行:
执行修改数据 app.content='1111',会触发
执行app.$destroy(),会触发
