columns:(表格项)
import { NText } from 'naive-ui';
import { h } from 'vue';
const statusOptions = {
1: { text: '种类1', type: '' },
2: { text: '种类2', type: '' },
};
export const columns = [
{ type: 'selection', key: 'selection' },//复选框列
{
title: '序号',
width: 40,
align: 'center',
render: (text: any, record: any, index: any) => {
return record + 1;
},
},
{
title: '标题',
key: 'content',
width: 100,
align: 'center',
},
{
title: '类型',
key: 'type',
width: 100,
align: 'center',
render(row) {
return h(
NText,
{
type: statusOptions[row.type].type,
},
{ default: () => statusOptions[row.type].text }
);
},
},
];
request请求
const loadDataTable = async (res) => {
tableData.value = await getList({ ...params.value, ...res });
return tableData.value;
};
这段内容展示了如何在Vue应用中使用Naive UI库来渲染带有选择框、序号、标题和类型信息的表格。代码片段定义了表格列的配置,包括自定义渲染类型字段,同时提供了一个异步加载数据的方法`loadDataTable`,该方法用于获取并更新表格数据。
1137

被折叠的 条评论
为什么被折叠?



