首页 > 技术文章 > vue2.0 子组件 父组件之间的传值

xiangsj 2017-12-21 17:18 原文

常用的子组件给父组件传值/调父组件方法

//子组件
let val = "";//可以是任意类型
this
.$emit('fatherFun', val);
//父组件
<father-component-name v-on:fatherFun="fatherFunction"></father-component-name>
//fatherFunction 可以接收子传来的值val,也可以为空,只是执行一个方法
//还可以直接写如:“isShow=!isShow”

 

双向通信:

https://www.cnblogs.com/gsgs/p/7294160.html

 

.

推荐阅读