np-table 表格

配置驱动视图的表格,通过 columns 动态生成表格,用法简单且具有高扩展性。

基础用法

表格主要通过 option 配置 columns 动态生成表格,api.fetch 获取数据。

浏览器不支持,请手动复制 basic.vue

组件配置

Props

属性说明类型默认值
option配置参数TableOption-

类型定义

组件导出以下类型定义

import type { TableOption, TableColumn, TableFilter } from 'naive-plus'

TableOption

属性说明类型默认值
columns表格列Array<TableColumn>-
api数据接口{ fetch: (pageParams, otherParams) => Promise<{ items, itemCount? }> }-
props表格属性,会透传给 n-data-table。为避免表格内部纵向滚动遮挡页面内容,会忽略 maxHeightflexHeightvirtualScroll 等纵向滚动相关配置object-
pagination分页配置,设为 false 可禁用分页false / PaginationConfig-
filters筛选器配置Array<TableFilter>-

TableColumn

属性说明类型默认值
key列字段名称string-
title列标题string / ComputedRef<string>-
render自定义渲染函数(rowData, rowIndex) => VNode-
type列类型'selection' / 'index' / 'expand'-
width列宽度string / number-
minWidth列最小宽度string / number-
fixed列固定位置'left' / 'right'-
display列是否显示booleantrue