雖說用vue有一年三個月?大概吧,但是說生命週期,我居然說不出來,我果然是個菜的,🤤。生命週期對我們來說很重要,因爲在哪個階段做哪些操作還是要掌握的,不然可能會出bug,出了bug,扣績效,扣年終獎,可怕可怕,當然這是我自己臆想的,臆想的小姐姐總是最美的。偶吼吼😋
看看之下的代碼,然後看控制檯輸出,發現了什麼?
<template>
<div id="app">
<div class="container" style="height: 100%;">
{{num}}
<button @click="clickMe">點擊我</button>
</div>
</div>
</template>
<script>
name: 'App',
data() {
return {
num: 0,
}
},
beforeCreate() {
console.log('----beforeCreate')
},
created() {
console.log('----created')
},
beforeMount() {
console.log('----beforeMount')
},
mounted() {
console.log('----mounted')
},
beforeUpdate() {
console.log('----beforeUpdate')
},
updated() {
console.log('----updated')
},
beforeDestroy() {
console.log('----beforeDestroy')
},
destroyed() {
console.log('----destroyed')
},
methods: {
clickMe() {
this.num++
},
}
}
</script>
載入頁面時:
點擊按鈕時:
跳轉至另外一個路由:
this.$router.push({
path:'/b'
})
再細說vue生命週期,有什麼好說的,盜圖爲敬~~,做圖的大大千萬別打我,☹️~~
這是個面試題集錦來着🤔
再上另外一篇大大的圖,大同小異,就取小異看看好了
我就要張圖!😈