
Security News
Frontier AI Is Now Critical Infrastructure
The Fable shutdown shows how quickly model access can become a business continuity risk for AI-dependent engineering teams.
cx-smart-table
Advanced tools
SmartTable 是一个 基于 Vue 3 + Element Plus 的高可复用表格组件,面向 中后台系统 场景设计,强调:
SmartTable/
├─ column/
│ ├─ index.vue # TableColumn 子组件
│ └─ renderer.ts # renderer 注册中心
├─ hooks/
│ ├─ useOperationColumn.ts # 操作列按钮可见性 / 宽度逻辑
│ └─ useTableColumns.ts # 列显隐缓存(只缓存 visible)
├─ index.vue # SmartTable 主组件
├─ types.ts # ColumnConfig / ButtonConfig 类型
└─ README.md
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| data | any[] | [] | 表格数据 |
| columns | ColumnConfig[] | [] | 列配置(支持 v-model:columns) |
| rowKey | string | 'id' | 行唯一 key |
| loading | boolean | false | loading 状态 |
| permissions | string[] | [] | 当前用户权限列表 |
| pageKey | string | - | 列缓存 pageKey(可选) |
| userId | string | number | - | 列缓存 userId(可选) |
其余属性将 透传给 el-table。
export interface ColumnConfig<R = any> {
type?: 'selection' | 'index' | 'operation'
key?: string
label?: string
visible?: boolean
inControl?: boolean
render?: string
editable?: boolean
editType?: 'input' | 'number' | 'select'
renderProps?: Record<string, any>
columnProps?: Record<string, any>
formatter?: (value: any, row: R) => any
/** operation 专用 */
buttons?: ButtonConfig<R>[]
maxbtn?: number
/** 内部字段(SmartTable 自动注入) */
__rows?: R[]
}
selection / index / operation 为 核心列inControl = falsevisible 控制显示 / 隐藏export interface ButtonConfig<R = any> {
permission?: string | string[]
label: string
type?: 'primary' | 'success' | 'warning' | 'danger' | 'info'
action: (row: R) => void
/** 行级可见性 */
visible?: (row: R) => boolean
/** 用于宽度计算 */
width?: number
}
整个操作列是否显示 = 是否存在“至少一个行 + 至少一个按钮可见”
visible(row) === false → 不显示| renderer | 说明 |
|---|---|
html | 原生 HTML(ellipsis) |
copy | 可复制文本(hover 显示按钮 + ElMessage) |
img | 图片预览 |
dict | 字典映射 |
map | key-value 映射 |
formatter | 自定义格式化 |
editable | 可编辑单元格(input / number / select) |
icon | iconfont / svg / url |
{
key: 'username',
label: '用户名',
render: 'copy'
}
特性:
ElMessage{
key: 'avatar',
label: '头像',
render: 'img',
renderProps: { style: 'width:50px;height:50px' }
}
const providerMap = {
aa: 'xxx',
bb: 'xxxx',
cc: 'xxxxxx'
}
{
visible: true,
key: "status",
label: "状态",
render: "map",
renderProps: {
options: providerMap,
},
columnProps: { width: 80, sortable: true}
},
const Enables = [
{ label: '启用', value: 1, listClass: 'primary' },
{ label: '禁用', value: 0, listClass: 'warning' }
]
{
key: "status",
label: "状态",
visible: true,
render: "dict",
renderProps: {
options: Enables,
},
columnProps: { width: 80, sortable: true}
},
{
key: 'price',
label: '价格',
render: 'formatter',
formatter: (val) => `$${val}`
}
{
key: 'age',
label: '年龄',
render: 'editable',
editable: true,
editType: 'number',
renderProps: { min: 0, max: 120 }
}
{
key: 'icon',
label: '图标',
render: 'icon',
renderProps: { style: 'color:red;font-size:24px' }
}
const { columns } = useTableColumns(defaultColumns, {
pageKey: 'user-list',
userId: currentUserId
})
userId / pageKey 由调用方决定<SmartTable
:data="tableData"
v-model:columns="columns"
:permissions="userPermissions"
:user-id="userId"
page-key="user-list"
@cellChange="onCellChange"
/>
FAQs
基于 Vue 3 + Element Plus 的高可复用表格组件
We found that cx-smart-table demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
The Fable shutdown shows how quickly model access can become a business continuity risk for AI-dependent engineering teams.

Security News
AI agents are pulling packages into environments no scanner is watching, creating exposure before security teams can see it.

Security News
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.