此篇文章为table表格示例,包含列、data数据、展开、选中、自定义等相关属性
基础表格
<a-table :columns="columns1" :data="tableData1" />
const columns1 = [
{ title: "编号", dataIndex: "no"},
{ title: "名称", dataIndex: "name"},
{ title: "性别", dataIndex: "sex"},
{ title: "年龄", dataIndex: "age", slotName: "age"}
];
const tableData1 = reactive([
{ name: "张三", no: "01", sex: "男",age:26 },
{ name: "秀儿", no: "02", sex: "女",age:25 },
{ name: "李四", no: "03", sex: "男",age:27 }
]);
可编辑表格
<!-- 需要编辑的列 在columns里加对应的 slotName -->
<a-table :columns="columns1" :data="tableData1">
<template #age="{ record, rowIndex }">
<a-input v-model="record.age" />
</template>
</a-table>