https://files-cdn.cnblogs.com/files/yummylucky/zhifu.bmp

支付宝

https://files-cdn.cnblogs.com/files/yummylucky/WeChat.bmp

微 信

vue子传父拦截器

今天跟大佬学到一个子传父的方法。

父组件data中定义一个变量 a ,定义一个方法  interceptor (val) {this.a = val} 

然后将这个方法传入子组件: <child-node :interceptor="interceptor"></child-node> 

 

在子组件中接收这个方法: props:{interceptor:{type: Function}} 

在子组件中调用拦截器方法: this.interceptor('childMsg') 

 

在父组件中打印便可以看到变量 a 中已经得到了子组件中传递的值。

posted @ 2019-06-22 14:23  kiss雪夜  阅读(281)  评论(0编辑  收藏  举报