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

久久伦理影院I美女亚洲精品I手机色在线I免费韩国avI国产手机免费视频I久久99视频免费I懂色av懂色av粉嫩av分享吧I日本精品一区二区在线观看I开心综合网I国产一区在线观看免费I日韩欧美一区二区三区在线I一区av在线播放I精品综合久久久I日韩一区二区在线免费观看I国产99在线播放I色射色I国产精品一区二区在线免费观看

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

2020/11/27 18:06:50   閱讀:7075    發布者:7075
一、使用 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 鉤子函數 ...


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

沒有了