2019-05-31 VUE中的「插槽」-「v-slot」
文章目录
当我们需要在父组件中,添加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方法的回调,就是向父组件传递的参数

评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论