父組件:@hook:mounted="watchChild",watchChild寫監聽到子組件生命週期觸發後,要走的邏輯
<template>
<div class="home">
<div>{{title}}</div>
//看這裏看這裏
<child @hook:mounted="watchChild"></child>
</div>
</template>
<script>
// @ is an alias to /src
// import pdf from "vue-pdf";
import child from "@/components/child/child";
export default {
name: "home",
data () {
return {
title: "父組件",
};
},
components: {
child
},
methods: {
// 監聽子組件觸發事件
watchChild () {
// 可以監聽到子組件mounted之後,獲取子組件的DOM節點的ref屬性
console.log(111)
}
}
};
</script>
子組件什麼都不用寫