当我们需要在父组件中,添加dom给子组件是,我们需要插槽v-slot
父组件
father.vue
<template>
<child>
<template #header="row">
// row 为子组件向父组件传递的参数
</template>
</child>
</template>
子组件
child.vue
<template>
<span>我在上面</span>
<slot name="header" :data="msg()"></slot>
<span>我在下面面</span>
</template>
<script>
export default {
methods:{
msg(){
return {
a:123
}
}
}
}
</script>
msg方法的回调,就是向父组件传递的参数