1、使用的场景:子组件有一部分内容需要灵活展示——由父组件提供,因此子组件需要留一个口子可以让父组件去发挥。

2、示例代码:



<!--子组件,child-->
<!--row为传递的参数,父组件可能需要使用-->
<template>
<slot name="operate" :row="row"/>
</template>


<!--父组件-->
<!--operate对应子组件插槽名称-->
<!--row即为传递的参数,如果有多个就逗号隔开-->
<template #operate="{ row }">
<!--要插入的code-->
</template>