看了这篇文章 优雅的使用 element-ui 中的 table 组件,突然顿悟了一些。
elment-ui的表格
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | <el-table :data= "tableData" > <el-table-column prop= "date" label= "日期" > </el-table-column> <el-table-column prop= "name" label= "姓名" > </el-table-column> <el-table-column prop= "address" label= "地址" > </el-table-column> </el-table> |
vben 是封装了一个table,
tableColumns,searchFormSchema,createFormSchema,updateFormSchema 在typescript 文件里定义
const [registerTable, { reload }] = useTable({ columns: tableColumns, formConfig: { labelWidth: 70, schemas: searchFormSchema, }, api: pageAsync, actionColumn: { width: 220, title: '操作', dataIndex: 'action', slots: { customRender: 'action' }, }, });
slot 占位符 单独定义内容
<BasicTable @register="registerTable" size="small"> <template #toolbar> <a-button preIcon="ant-design:plus-circle-outlined" type="primary" @click="openCreateProductModal" > 新增产品 </a-button> </template> <template #action="{ record }"> <TableAction :actions="[ { icon: 'clarity:note-edit-line', label: '编辑', tooltip: '编辑产品', onClick: handleEdit.bind(null, record), }, { icon: 'ant-design:delete-outlined', color: 'error', label: '删除', tooltip: '删除产品', popConfirm: { title: '是否确认删除', placement: 'left', confirm: handleDelete.bind(null, record), }, }, ]" /> </template> </BasicTable>
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· 什么是nginx的强缓存和协商缓存
· 一文读懂知识蒸馏
· Manus爆火,是硬核还是营销?