时间: 2020-11-25|61次围观|0 条评论

转载自:https://blog.csdn.net/a8725585/article/details/79092505

vue父子组件钩子函数触发顺序

beforeMount后mounted前构造子组件 依次遍历

beforeCreate-父组件
create-父组件
beforeMount-父组件
beforeCreate-子组件
create-子组件
beforeMount-子组件
beforeCreate-次子组件
create-次子组件
beforeMount-次子组件
mounted-次子组件
mounted-子组件

mounted-父组件

钩子函数发生的事

beforeCreate-组件刚实例化完成 el 和 data 都为undefined 
created-组件实例化完成 data 数据有值,Dom还未生成 el没有值

beforeMount-虚拟Dom已生成 el 和 data 有值 此时显示<span>{ {message}}</span>  俗称占坑

mounted-挂载完成 此时显示 <span>123 </span>

转载于:https://www.cnblogs.com/wuguanglin/p/theParentAndChildComponentLifeCycleofView.html

原文链接:https://blog.csdn.net/weixin_30342827/article/details/99791378

本站声明:网站内容来源于网络,如有侵权,请联系我们,我们将及时处理。

本博客所有文章如无特别注明均为原创。
复制或转载请以超链接形式注明转自起风了,原文地址《Vue父子组件生命周期
   

还没有人抢沙发呢~