小菜鸟,最近尝试用Vue3+ant 组件,遇见不少问题
背景 :ant table +vue3
vue3自定义列,官网介绍去掉了Vue2部分插槽写法
<a-table
:columns="columns"
:data-source="list"
:row-selection="rowSelection"
:rowKey="list.key"
bordered
>
<!-- 操作列 -->
<!-- v-slot:bodyCell="{ record }" -->
<!-- 自定义单元格事件 -->
<template #operate="scope">
<a-button @click="cellClick(scope.record)">
重新合作
</a-button>
</template>
</a-table>
自定义表头写法
const columns = [
{
title: '操作',
key: 'operate',
slots: { customRender: 'operate' }
}
]
自定义列单元格点击事件
// 单元格点击事件
const cellClick = function (cd: any) {
console.log('record', cd)
}
很多种写法,多多尝试,希望有用