上海网站建设网页制作,免费网站友情链接,12306网站 给手机核验怎么做,上海网站建设服务多少钱之前写过一篇文章#xff0c;vue中父组件添加自定义参数后#xff0c;如何获取子组件$emit传递过来的参数
现在已经进入vue3.x开发的时代了#xff0c;那么vue3.x中父组件添加自定义参数后#xff0c;如何获取子组件$emit传递过来的参数#xff1f;
1、子组件使用emit传…之前写过一篇文章vue中父组件添加自定义参数后如何获取子组件$emit传递过来的参数
现在已经进入vue3.x开发的时代了那么vue3.x中父组件添加自定义参数后如何获取子组件$emit传递过来的参数
1、子组件使用emit传过来的参数只有一个时父组件可以使用$event接收子组件传过来的参数
子组件child1
this.$emit(fromChild1,我是子组件传过来的参数--child1)父组件
child1 fromChild1($event) getChild1($event,我是父组件中的自定义参数--parent1)/child1getChild1($event,parameter){console.log($event); // 我是子组件传过来的参数--child1console.log(parameter); // 我是父组件中的自定义参数--parent1
},console.log打印结果: 我是子组件传过来的参数--child1我是父组件中的自定义参数--parent1
大家可以对比一下vue3和vue2的写法看看有什么不同点。