将表格二次封装,方便以后开发中的复用。每次只需调用表格组件后,在父组件中往子组件标签上写入dataSource(表格数据)和columns(表格列标题)即可。
此案例中最后一列是删除按钮,动态生成,在父组件中定义columns时用
slots: { customRender: "operation" } 来动态渲染。
在子组件的template标签中通过slot插槽来传值(每一行的值),在父组件中通过v-slot="slotProps"接收子组件传过来的值。
示例代码如下:
子组件MngTable.vue
<template>
<a-table :dataSource="dataSource" :columns="columns">
<template #operation="{ record }">
<slot :record="record"></slot>
</template>
</a-table>
</templat