Vue.js基础_生命周期
2019-08-06 22:28
1116 查看
生命周期函数
[code]<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <script src="js/vue.js"></script> </head> <body> <div id="demo"> <button @click="destoryVm">touch</button> <p v-show="isShow">i love you!</p> </div> </body> <script type="text/javascript"> var demo=new Vue({ el:'#demo', data:{ isShow:true, }, beforeCreate(){ console.log(' beforeCreate') }, created(){ console.log('created()') }, mounted(){//初始化显示之后立即调用 this.intervalId=setInterval(()=>{ console.log('-----') this.isShow=!this.isShow },100) }, //更新阶段(1次或者n次) beforeUpdate(){ console.log('beforeUpdate()') }, update(){ console.log('update()') }, //死亡阶段 beforeDestroy(){ //清除定时器 console.log('beforeDestroyed()') clearInterval(this.intervalId) }, destroyed(){ console.log('destroyed()') }, methods:{ destoryVm(){ //干掉vm this.$destroy() } } }) </script> </html>
Vue生命周期图示
相关文章推荐
- vue.js基础-属性与方法和实例生命周期
- Vue.js基础知识汇总
- vue.js基础-处理用户输入与双向数据绑定
- vuejs组件的生命周期
- vue.js基础
- vue.js基础(5)
- vue.js 生命周期代码详解
- Vue.js组件——组件的基础知识
- Vue.js基础学习---set/get方法
- 最细致的vue.js基础语法 值得收藏!
- vue.js(2.x)基础版
- vue.js基础-组件
- Vue.js 2.0学习教程之从基础到组件详解
- Vue.js 子组件的异步加载及其生命周期控制
- [js框架]Vue框架的基础学习 一、模板语法的使用
- 2019年最全Vue.Js从基础到实战案例高级课程大合集12套教程
- Vue.js基础_过滤器
- vue2.0+基础知识连载(11)--- 生命周期
- vue.js基础笔记
- Vue.js 生命周期的应用