# 表格组件使用说明 > 基于 `page-table` + `page-dialog-form` 的新一?CRUD 表格方案? > 源码位置:`src/components/page-table/`、`src/components/page-dialog-form/`、`src/composables/` > 完整可运行示例:`src/views/production-master-data/factory-model/factory-area/index.vue` --- ## 目录 1. [快速开始(三步走)](#1-快速开始三步走) 2. [完整示例代码](#2-完整示例代码) 3. [组件 API 参考](#3-组件-api-参? 4. [Composable API 参考](#4-composable-api-参? 5. [i18n 国际化方案](#5-i18n-国际化方? 6. [常用场景速查](#6-常用场景速查) 7. [路由配置](#7-路由配置) 8. [API 文件写法](#8-api-文件写法) 9. [旧代码迁移对照](#9-旧代码迁移对? 10. [常见问题排查](#10-常见问题排查) --- ## 1. 快速开始(三步走) ### 第一步:定义列和按钮(`created()` 中) ```js import { useTableColumns } from '@/composables/useTableColumns' import { useTableButtons } from '@/composables/useTableButtons' import { i18nMixin } from '@/composables/useI18n' export default { mixins: [i18nMixin('page.模块?二级模块.三级模块')], created () { // --- 列定?--- // 只需声明 prop ?label,idx 自动补齐 // prop: '_actions' 约定为操作列,自动渲?rowButtons this.columns = useTableColumns([ { prop: 'sort', label: this.key('sort'), width: 80 }, { prop: 'code', label: this.key('code'), minWidth: 120 }, { prop: 'name', label: this.key('name') }, { prop: '_actions', label: this.key('operation'), width: 160, fixed: 'right' } ]) // --- 按钮定义 --- // 不再分开?buttonList / tableButtonList const btns = useTableButtons({ toolbar: [ { key: 'add', label: this.key('add'), icon: 'el-icon-plus', type: 'primary', auth: '/xxx/create', onClick: this.openAdd } ], row: [ { key: 'edit', label: this.key('edit'), icon: 'el-icon-edit', auth: '/xxx/edit', onClick: this.openEdit }, { key: 'delete', label: this.key('delete'), icon: 'el-icon-delete', color: 'danger', auth: '/xxx/delete', onClick: this.handleDelete } ] }, this.$permission) // ?第二个参数传入权限校验函? this.toolbarButtons = btns.toolbarButtons this.rowButtons = btns.rowButtons } } ``` ### 第二步:写模板(`