摘要:
四、兄弟组件间通信(event) 借助于一个公共的Vue的实例对象,不同的组件可以通过该对象完成事件的绑定和触发 var bus = new Vue(); bus.$emit()bus.$on() 熊大想要发消息给熊二, 接收方(熊二):事件绑定 bus.$on('customEvent',func 阅读全文
摘要:
组件间通信综合练习:(props down,events up)有2个组件:chat-room,user-componentuser-component是由label input button构成chat-room是由两个user-component和一个列表构成 ①在chat-room调用user 阅读全文
摘要:
三、组件间通信($parent $refs) 父组件要想获取子组件的数据:①在调用子组件的时候,指定ref属性<child-component ref="mySon"></child-component> ②根据指定的引用的名字 找到子组件的实例对象this.$refs.mySon 子组件要想获取父 阅读全文
摘要:
子组件传递数据 用户已经登录 父组件接收数据 并显示列表,未登录不显示列表 /* 有两个组件,分别是main-component,header-component.main-component是由header-component和一个列表(有5条数据 [100,200,300,400,500]),h 阅读全文
摘要:
二、组件间通信(子组件传值给父组件) 通过事件的方式来完成数据的传输。 ①在父组件中 定义一个方法,用来接收子组件所通过事件传来的值 methods:{ recvMsg:function(msg){ //参数msg就是子组件通过事件出来的数据 }} ②绑定事件处理函数事件一般情况 都是自定义事件 < 阅读全文
摘要:
一、组件间通信(父组件 --> 子组件)步骤:①父组件在调用子组件 传值 <child-component myValue="123"> </child-component>②在子组件中 获取父组件传来的值 Vue.component('child-component',{ props:['myVa 阅读全文