Appearance
尺寸
不同项目可通过 app.use(AdminProTable, options) 配置组件 / 按钮尺寸,无需在每个页面重复设置。
主题色请在业务项目中通过 Element Plus(或项目主题方案)统一配置,组件会自动跟随,无需在本库中再配置 theme。
快速配置
javascript
import { createApp } from 'vue'
import AdminProTable from 'admin-pro-table'
import 'admin-pro-table/dist/style.css'
const app = createApp(App)
app.use(AdminProTable, {
// 组件尺寸:large | default | small
size: 'default',
// 按钮尺寸(可选,默认与 size 一致;会作用到搜索/工具栏/操作列/表单底栏等全部内置按钮)
buttonSize: 'default',
// 仅改操作列按钮尺寸时用这个,不要用全局 buttonSize
operationConfig: { size: 'small' }
})配置项
| 属性 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| size | 全局组件尺寸,作用于表格、表单控件、分页等 | 'large' | 'default' | 'small' | Element Plus 默认 |
| buttonSize | 内置按钮尺寸(搜索、工具栏、操作列、表单底栏等) | 'large' | 'default' | 'small' | 同 size |
| operationConfig | 操作列全局默认;可用 { size: 'small' } 只改操作列按钮,不影响搜索/工具栏等 | Object | - |
影响范围
| 区域 | 说明 |
|---|---|
| 搜索区 | 输入框、下拉框、搜索/重置按钮 |
| 工具栏 | 返回、添加、删除及插槽旁内置按钮 |
| 表格 | el-table 行高(通过 tableProps.size 自动合并) |
| 操作列 | 编辑、删除、复制及 operation-before/after 旁按钮 |
| 分页底栏 | 刷新按钮 |
| 表单弹层 | 表单控件与取消/保存/提交按钮 |
| 独立 ProForm | 同上 |
单页覆盖
可在 tableConfig、searchConfig、formConfig 上局部覆盖:
javascript
const tableConfig = {
size: 'small',
buttonSize: 'small',
operationConfig: { size: 'small' },
toolbarConfig: { size: 'small' }
}
const searchConfig = {
size: 'small',
actionsConfig: { size: 'small' }
}
const formConfig = {
formAttrs: { size: 'small' },
footer: { size: 'small' }
}优先级:
text
区域配置(operationConfig / toolbarConfig / footer 等)
> 当前页面 tableConfig / searchConfig / formConfig
> app.use 全局配置
> Element Plus 默认修改 size / buttonSize 后,建议给 pro-table 设置 :key 触发重新挂载,以确保所有内置按钮尺寸立即更新:
vue
<pro-table :key="`${globalOptions.size}-${globalOptions.buttonSize}`" ... />本地 examples 演示见 尺寸 菜单(/size-settings)。
与 tableProps / formAttrs 的关系
全局 size 会自动合并进 tableProps 与 formAttrs,无需重复写:
javascript
app.use(AdminProTable, {
size: 'small',
tableProps: { border: true, stripe: true }, // 自动带上 size: 'small'
formConfig: { labelWidth: '100px' } // formAttrs 自动带上 size: 'small'
})若显式配置了 tableProps.size 或 formAttrs.size,则以显式值为准。