// Child.vue mounted() {this.$emit("mounted");} " >

丁香花完整视频在线观看-午夜爽爽爽-亚洲777-女同一区二区-国产伊人网-国产乱码精品一品二品-天堂色av-伊人影院av-午夜中文字幕-久久精品片-男女视频在线观看免费-中文字幕久久网-欧美www视频-非洲黑妞xxxxhd精品-亚洲午夜精品在线-亚洲中午字幕-精品国产aⅴ-日本高清视频在线-成年人免费大片-亚洲精品视频在线免费

Vue 中父組件可以監聽到子組件的生命周期

2020/11/27 18:06:50   閱讀:6817    發布者:6817
一、使用 on 和 emit
// Parent.vue
<Child @mounted="doSomething"/>
// Child.vue
mounted() {
  this.$emit("mounted");
}

二、使用 hook 鉤子函數
//  Parent.vue
<Child @hook:mounted="doSomething" ></Child>

doSomething() {
   console.log('父組件監聽到 mounted 鉤子函數 ...');
},
//  Child.vue
mounted(){
   console.log('子組件觸發 mounted 鉤子函數 ...');
},
// 以上輸出順序為:
// 子組件觸發 mounted 鉤子函數 ...
// 父組件監聽到 mounted 鉤子函數 ...


移動端適配方案具體實現以及對比

沒有了