# antdv-pro-layout **Repository Path**: TsMask/antdv-pro-layout ## Basic Information - **Project Name**: antdv-pro-layout - **Description**: 【Vue3】Ant Design Pro布局Vue,易于使用专业脚手架。 - **Primary Language**: TypeScript - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 6 - **Forks**: 3 - **Created**: 2023-10-30 - **Last Updated**: 2026-07-22 ## Categories & Tags **Categories**: Uncategorized **Tags**: Vue, Ant-Design, TypeScript ## README # Ant Design Vue Pro Layout Ant Design Pro Vue 布局,易于使用专业脚手架。 [](./package.json) [](https://www.npmjs.com/package/antdv-pro-layout) [](https://www.npmjs.com/package/antdv-pro-layout)  [中文](./README.md) | [English](./README.en.md) ## 安装 Install ```bash npm i antdv-pro-layout ``` ## 简单使用 Simple Usage 首先,您应该将所需的 `antdv-pro-layout` 添加到库中。 ```js // main.[js|ts] import { createApp } from "vue"; import App from "./App.vue"; import "ant-design-vue/dist/reset.css"; import Antd from "ant-design-vue"; import "antdv-pro-layout/dist/style.css"; import { ProLayout, PageContainer } from "antdv-pro-layout"; const app = createApp(App); app.use(Antd).use(ProLayout).use(PageContainer).mount("#app"); ``` 之后,您可以在 Vue 组件中使用专业布局,如下所示: ```vue ``` ## 库功能支持 API ### 函数布局 ProLayout | 名称 | 说明 | 参数 | 返回值 | | --- | --- | --- | --- | | `MediaQueryEnum` | 屏幕尺寸媒体查询枚举对象 | - | 枚举 xs/sm/md/lg/xl/xxl/xxxl | | `getMediaScreen()` | 当前屏幕尺寸 | - | `MediaQueryKey` | | `useMediaScreen()` | 屏幕尺寸响应式监听(自动清理) | - | `Ref` | | `PrefersColorSchemeEnum` | 主题颜色模式枚举对象 | - | 枚举 light/dark | | `getPrefersColorScheme()` | 系统主题颜色模式偏好 | - | `PrefersColorSchemeKey` | | `usePrefersColorScheme()` | 主题颜色模式偏好响应式监听 | - | `Ref` | | `viewTransitionTheme(listener, e?)` | 主题切换视图过渡动画 | `listener: (isDark) => void``e?: { clientX, clientY }` | `void` | | `getMenuData(routes)` | 路由表转系统菜单,仅取 `/` 子树 | `routes: readonly RouteRecordRaw[]` | `{ menuData, breadcrumb }` | | `clearMenuItem(routes)` | 清除隐藏/无 `name` 的菜单项 | `routes: readonly RouteRecordRaw[] \| readonly RouteRecord[]` | `RouteRecordRaw[]` | ### 组件布局 ProLayout | 参数 | 说明 | 类型 | 默认值 | | --- | --- | --- | --- | | title | 布局 LOGO 右侧文本 | string | `'Ant Design Vue Pro'` | | logo | 布局 LOGO,支持链接 / VNode / 渲染函数 | string \| VNode \| Function | - | | logoStyle | 布局 LOGO 图样式 | object | - | | iconfontUrl | Iconfont Symbol 脚本地址 | string | `''` | | loading | 布局内容区加载等待状态 | boolean | `false` | | pure | 纯净模式,仅渲染默认插槽(无布局外壳) | boolean | `false` | | isChildrenLayout | 是否为嵌套子布局 | boolean | - | | contentStyle | 布局内容区自定义样式 | object \| string | - | | layout | 菜单布局 | 'side' \| 'top' \| 'mix' | `'side'` | | theme | 全局主题色 | 'light' \| 'dark' | `'light'` | | menuTheme | 菜单导航主题色 | 'light' \| 'dark' | `'light'` | | menuData | 菜单项数据 [`MenuDataItem[]`](dist\types\typings\index.d.ts) | Array | `[]` | | collapsed | 菜单左侧收起展开 | boolean | `false` | | collapsedWidth | 菜单左侧收起宽度大小 | number | `48` | | siderWidth | 菜单左侧展开宽度大小 | number | `200` | | selectedKeys | 菜单选择高亮 keys | string[] | `[]` | | openKeys | 菜单选择打开展开 keys | string[] | `[]` | | matchMenuKeys | 菜单高亮匹配 keys | string[] | `[]` | | breakpoint | 侧边栏响应式断点,传空串 `''` 关闭 | string \| object | `'md'` | | breadcrumb | 布局内容左上角面包屑 | object \| Function | - | | fixSiderbar | 菜单左侧列表固定 | boolean | `false` | | fixedHeader | 顶部区域固定 | boolean | `false` | | headerHeight | 顶部区域高度 | number | `48` | | splitMenus | 菜单布局`mix`分割二级菜单到左侧 | boolean | `false` | | locale | 菜单名国际化函数处理,传 `false` 关闭 | (menuDataItem?: MenuDataItem) => string \| `false` | `false` | | menuHeaderRender | 渲染菜单头 logo 和标题区域 | v-slot \| VNode \| (props) => VNode \| false | - | | menuHeaderExtraRender | 渲染菜单头拓展区域 | v-slot \| VNode \| (props) => VNode \| false | - | | menuContentRender | 渲染整个菜单内容区域 | v-slot#menuContentRender="props" | - | | menuFooterRender | 渲染菜单底脚区域 | v-slot \| VNode \| (props) => VNode \| false | - | | menuItemRender | 渲染菜单项 Menu.Item | v-slot#menuItemRender="menuItem" | - | | menuSubItemRender | 渲染菜单嵌套子项 Menu.SubItem | v-slot#menuSubItemRender="menuItem" | - | | collapsedButtonRender | 渲染菜单收起按钮区域 | v-slot#collapsedButtonRender="collapsed" | - | | headerRender | 渲染顶部区域,传 `false` 隐藏 | v-slot \| VNode \| (props) => VNode \| false | - | | headerContentRender | 渲染顶部内容区域,仅布局`side`有效 | v-slot \| (props) => VNode | - | | headerContentRightRender | 渲染顶部内容右端区域 | v-slot \| (props) => VNode | - | | footerRender | 渲染底部区域,传 `false` 隐藏 | v-slot \| ({ width, ...props }) => VNode | - | | tabRender | 渲染顶部标签页区域,传 `false` 隐藏 | v-slot \| ({ width, ...props }) => VNode | - | | breadcrumbRender | 渲染面包屑导航区域 | v-slot \| ({ route, params, routes, paths }) => VNode[] | - | | collapse | 菜单收起展开触发事件 | (collapsed: boolean) => void | - | > 菜单数据可通过提供的 `getMenuData` 和 `clearMenuItem` 函数转换 > 例如 `const { menuData } = getMenuData(clearMenuItem(routes))` #### 插槽渲染 Custom Render ##### 渲染顶部内容区域 headerContentRender ```vue headerContentRender Avatar ``` ##### 渲染菜单项 menuItemRender Menu.Item ```vue {{ meta?.title }} ``` ##### 渲染顶部头区域 breadcrumbRender ```vue {{ route.breadcrumbName }} {{ route.breadcrumbName }} ``` ##### 渲染顶部标签页区域 tabRender ```vue tabRender fixedHeader:{{ fixedHeader }} width:{{ width }} ``` ##### 渲染底部区域 footerRender ```vue ``` ### 组件页脚 GlobalFooter | 参数 | 说明 | 类型 | 默认值 | | --- | --- | --- | --- | | links | 必填,链接跳转 | Array<{ key?: string; title: string; href: string; blankTarget?: boolean; }> | - | | copyright | 版权声明区域 | string \| VNode \| v-slot | undefined | ```vue ``` ### 组件内容页 PageContainer 包含 antdv 组件 API 属性: [PageHeader 页头](https://www.antdv.com/components/page-header-cn#api)、[Affix 固钉](https://www.antdv.com/components/affix-cn#api) | 参数 | 说明 | 类型 | 默认值 | | --- | --- | --- | --- | | loading | 加载状态 | boolean | false | | disableMargin | 布局内容禁用外边距 `24px` | boolean | false | | flex | 内容布局是否充满宽度 | boolean | true | | fixed-header | 固定 PageHeader 到顶部 | boolean | false | | affixProps | 固钉的配置 | [affix](https://www.antdv.com/components/affix-cn#api) | - | | pageHeader | 渲染页头替换 PageHeader 组件插槽 | VNode \| v-slot | - | | pageFooter | 渲染页脚插槽 | VNode \| v-slot | - | | content | PageHeader 默认插槽 | VNode \| v-slot | - | | contentExtra | PageHeader 默认插槽右侧空间 | VNode \| v-slot | - | | breadcrumb | PageHeader 面包屑的配置,`{}` 不显示 | [breadcrumb](https://www.antdv.com/components/breadcrumb-cn/) | - | | tab-list | PageHeader footer 插槽无时显示标签列表 | `Array<{ key: string; tab: any }>` | - | | tab-active-key | 标签列表当前激活 key | string | - | | tab-change | 标签列表 tab 被点击的回调 | (key) => void | - | | tab-props | 标签列表标签页属性 | [tabs](https://www.antdv.com/components/tabs-cn) | - | | ... | PageHeader 属性 | [PageHeader 页头 API](https://www.antdv.com/components/page-header-cn#api) | - | ## 基本使用示例 Basic Usage 项目目录下 [演示测试](./playground/) or [项目引用示例](https://gitee.com/TsMask/mask_vue3_antd) 测试[stackblitz](https://stackblitz.com/edit/vitejs-vite-kvjk61?file=package.json,src%2Fmain.ts,src%2FApp.vue,src%2Fcomponents%2FHelloWorld.vue&terminal=dev) ## 源项目仓库分支 Branch 来自 [@ant-design-vue/pro-layout](https://github.com/vueComponent/pro-components) - next : Vue3 + `ant-design-vue@3.x` (latest) - v3.1 : Vue3 + `ant-design-vue@2.2.x` (release LTS) - v2 : Vue2 + `ant-design-vue@1.7.x` 当前版本 Vue3 + ant-design-vue@4.2.6 ([v4](https://gitee.com/TsMask/antdv-pro-layout)) ## 持续维护 Continuous Maintenance ```bash # 安装所需依赖 npm install # 打包生成dist目录含d.ts文件 npm run build ```