vue2的生命周期:
beforeCreate——>created——>beforeMount——>mounted——>beforeUpdate
——>updated——>beforeDestroy——destroyed
var myVue = new Vue({ el: '#app', data: { data: 'aaaa', info: 'nono' }, beforeCreate: function () { console.log('创建前=======') console.log(this.data) console.log(this.$el) }, created: function () { console.log('已创建==========') console.log(this.info) console.log(this.$el) }, beforeMount: function () { console.log('mount之前=============') console.log(this.info) console.log(this.$el) }, mounted: function () { console.log("mounted==========") console.log(this.info) console.log(this.$el) }, beforeUpdate: function () { console.log('更新前========') }, updated: function () { console.log('更新完成=============') }, beforeDestory: function () { console.log('销毁前============') console.log(this.info) console.log(this.$el) }, destoryed: function () { console.log('已销毁===========') console.log(this.info) console.log(this.$el) } });
原博客地址: