Vue 钩子函数
Vue 钩子函数
Vue.component('Test', { props: { name: String }, template: `<div class="test">{{ name }}</div>`, beforeCreate() { console.log('Test beforeCreate'); }, created() { console.log('Test created'); }, mounted() { console.log('Test mounted'); }, beforeDestroy() { console.log('Test beforeDestroy'); }, destroyed() { console.log('Test destroyed'); }, beforeUpdate() { console.log('Test beforeUpdate'); }, updated() { console.log('Test updated'); } }); Vue.component('Test1', { props: { name: String }, template: '<div class="test1"><slot />{{ name }}</div>', beforeCreate() { console.log('Test1 beforeCreate'); }, created() { console.log('Test1 created'); }, mounted() { console.log('Test1 mounted'); }, beforeDestroy() { console.log('Test1 beforeDestroy'); }, destroyed() { console.log('Test1 destroyed'); }, beforeUpdate() { console.log('Test1 beforeUpdate'); }, updated() { console.log('Test1 updated'); } });