【Vue】vue组件的通信方式有哪几种?(约85字)

props/$emit 父子组件通信

父->子props,子->父 o n 、 on、 on、emit 获取父子组件实例 parent、children Ref 获取实例的方式调用组件的属性或者方法

父->子孙 Provide、inject 官方不推荐使用,但是写组件库时很常用

emit/ emit/on 自定义事件 兄弟组件通信

Event Bus 实现跨组件通信 Vue.prototype.$bus = new Vue() 自定义事件

vuex 跨级组件通信

Vuex、 a t t r s 、 attrs、 attrs、listeners Provide、inject

THE END
喜欢就支持一下吧
点赞0 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容