vue3父传子
作者:互联网
1.father.vue
<template>
<div>
<Son :data=name></Son>
</div>
</template>
<script>
import Son from './son'
export default {
components:{
Son
},
setup() {
const name = '小范'
return{
name
}
}
}
</script>
2.son.vue
<template>
<div>
{{data}}
</div>
</template>
<script>
export default {
props:['data'],
setup(props,context) {
console.log(props)
console.log(context)
console.log(props.data,'father text')
return{
}
}
}
</script>
setup的两个参数.props接收 context传出
标签:console,log,setup,vue3,父传子,context,props,data 来源: https://blog.csdn.net/weixin_42821697/article/details/121515603