父传子
父组件:
<template>
<div class="son">
<son1 :toChild="toChild" />
</div>
</template>
<script>
import { reactive, toRefs } from 'vue'
import son1 from './branch/son1.vue'
export default {
components: {
son1
},
setup(props,context) {
const data = reactive({
toChild: '传递数据1'
})
return {
...toRefs(data)
}
}
}
</script>
子组件
// 第一种-------------------配置setup-------------------
<script>
export default {
props: { //这里必须写,不然setup中的props也拿不到
toChild: {
type: String,
default: '无数据'
}
},
setu