Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

231.[vue]Vue的生命周期 #231

Open
webVueBlog opened this issue May 12, 2020 · 1 comment
Open

231.[vue]Vue的生命周期 #231

webVueBlog opened this issue May 12, 2020 · 1 comment
Labels
vue vue

Comments

@webVueBlog
Copy link
Member

[vue]

@webVueBlog webVueBlog added the vue vue label May 12, 2020
@webVueBlog
Copy link
Member Author

activated钩子函数:在keep-alive模式下(vue对象存活【存在页面缓存】时,只要进入页面就会立即触发activated函数,用于多次访问页面时进行对页面数据进行初始化等操作)

created/onLoad钩子函数:同样的,created/onLoad钩子也可以用来初始化页面和数据使用,但仅在首次创建或重启时触发,在一个生命周期内,created/OnLoad仅会触发一次!

beforeCreate(){
      console.log("创建前===>胚胎")
}
created(){
      console.log("创建完成===>出生")
},
beforeMount(){
      console.log("挂载前===>幼儿园")
}
activated(){
      console.log("激活===>课外班:知识升级")
},
deactivated(){
      console.log("停止===>逃课打架:自暴自弃(多用于离开页面,比如切换页签(?))")
}
mounted(){
      console.log("挂载结束===>小学:知识消化(多用于配合监听及跨页面数据加载使用)")
}
beforeUpdate(){
      console.log("更新前===>初中:知识迭带(多用于异步更新前对页面数据的处理)")
}
updated(){
      console.log("更新完成===>高中:知识巩固")
}
beforeDestroy(){
      console.log("销毁前===>大学:思维碰撞(多用于关闭页面时对页面数据的操作)")
}
destroyed(){
      console.log("销毁完成===>毕业:现实世界(销毁页面时的操作,比如数据缓存清空等)")
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
vue vue
Projects
None yet
Development

No branches or pull requests

1 participant