This repository has been archived by the owner on Jun 6, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 141
文档翻译 - 组件间通信 (Communicate Between Components) #14
Comments
父组件向多个子组件通信 部分 使用的两个 foo 组件,应该一个foo,一个bar吧 |
@zjnxyz foo中也有包含bar的,所以还是属于子节点的 |
拷贝上述代码,完善template里面的组件,报错: Uncaught RangeError: Maximum call stack size exceeded, |
@shbIOS 先简单确认一下文件名和自定义标签名字是不是同名了,这样依赖判断会产生无限循环 |
兄弟组件通信的这个demo都不全,怎么测试啊 |
这几个例子根本跑不通呀,连imageUrl和image-url都没有对应起来 |
@shbIOS @jiangfei891111 |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
组件间通信
0.4
子组件向父组件通信
子组件能通过
this.$dispatch([String type], [Object detail])
方法向父组件传送数据。第一个参数代表数据类型(个人理解应该是叫通信事件名更好理解) , 第二个参数则是数据对象。如果子组件的某个父组件通过$on([String type], [Function callback])
方法注册了一个相同名字的属性监听,那么callback函数将得到一个参数对象,并且参数对象的detail属性值为子组件传递出来的数据对象。eg:
父组件向子组件通信
父组件能通过
this.$([String id])
获取子组件的上下文,你能通过这个上下文对象修改子组件相关信息。eg:
父组件向多个子组件通信
父组件能通过
this.$broadcast([String type], [Object detail])
方法像所有的子组件分发消息。兄弟组件间通信
兄弟组件能通过父组件作为桥梁进行通信。
The text was updated successfully, but these errors were encountered: