np-table Table
A configuration-driven table that dynamically generates the table through columns, simple to use and highly extensible.
Basic Usage
The table is dynamically generated by configuring columns through option, and data is fetched through api.fetch.
basic.en.vue
Component Configuration
Props
| Prop | Description | Type | Default |
|---|---|---|---|
| option | Configuration | TableOption | - |
Types
The component exports the following type definitions:
import type { TableOption, TableColumn, TableFilter } from 'naive-plus'
TableOption
| Prop | Description | Type | Default |
|---|---|---|---|
| columns | Table columns | Array<TableColumn> | - |
| api | Data API | { fetch: (pageParams, otherParams) => Promise<{ items, itemCount? }> } | - |
| props | Table props, passed through to n-data-table. To prevent the table's internal vertical scroll from covering page content, scroll-related configs like maxHeight, flexHeight, and virtualScroll will be ignored | object | - |
| pagination | Pagination config; set to false to disable pagination | false / PaginationConfig | - |
| filters | Filter config | Array<TableFilter> | - |
TableColumn
| Prop | Description | Type | Default |
|---|---|---|---|
| key | Column field name | string | - |
| title | Column title | string / ComputedRef<string> | - |
| render | Custom render function | (rowData, rowIndex) => VNode | - |
| type | Column type | 'selection' / 'index' / 'expand' | - |
| width | Column width | string / number | - |
| minWidth | Min column width | string / number | - |
| fixed | Fixed column | 'left' / 'right' | - |
| display | Whether to display the column | boolean | true |
