父组件:
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19data() { return { msg: '', resType: '', interestAlias: '', } }, methods: { onChange(event) { this.resType = event.target.value console.log(this.msg) }, getRes() { this.msg = [this.resType, this.interestAlias] console.log(this.msg) }, // 调用子组件 <FlowScheduleResult :msg="msg" />
子组件设置监听:
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22// 首先定义props props: { msg: { type: Array, required: true, }, }, // setup setup(props, context) { console.log('flow: ' + props.msg) }, // 监听数据变化 watch: { msg(newValue, oldValue) { console.log('sss:' + newValue) if (newValue) { this.parentData = newValue } }, },
最后
以上就是老实保温杯最近收集整理的关于vue3 动态传值给子组件的全部内容,更多相关vue3内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复