Home

Awesome

English | 简体中文

<h1 align="center">Ant Design Pro Layout</h1> <div align="center">

NPM version Vue Support NPM downloads License

</div>

Usage

npm i @ant-design-vue/pro-layout --save
// or
yarn add @ant-design-vue/pro-layout
import ProLayout from '@ant-design-vue/pro-layout'

// by jsx
export default {
  name: 'BasicLayout',
  render () {
    return (
      <ProLayout>
        <router-view />
      </ProLayout>
    )
  }
}
<template>
  <pro-layout
    :menus="menus"
    :collapsed="collapsed"
    :theme="theme"
    :layout="layout"
    :contentWidth="contentWidth"
    :auto-hide-header="autoHideHeader"
    :mediaQuery="query"
    :isMobile="isMobile"
    :handleMediaQuery="handleMediaQuery"
    :handleCollapse="handleCollapse"
  >
    <template v-slot:menuHeaderRender>
      <div>
        <img src="../assets/logo.svg" />
        <h1>Pro Layout</h1>
      </div>
    </template>
    <template v-slot:rightContentRender>
      <div :class="['ant-pro-global-header-index-right', layout === 'topmenu' && `ant-pro-global-header-index-${theme}`]">
        rightContentRender
      </div>
    </template>
    <template v-slot:footerRender>
      <div>footerRender</div>
    </template>
    <setting-drawer navTheme="dark" />
    <router-view />
  </pro-layout>
</template>

<script>

// by template
import ProLayout, { SettingDrawer } from '@ant-design-vue/pro-layout'
import { asyncRouterMap } from '../config/router.config'

export default {
  name: 'BasicLayout',
  data () {
    return {
      menus: [],
      collapsed: false,
      autoHideHeader: false,
      query: {},
      layout: 'sidemenu',
      contentWidth: 'Fluid',
      theme: 'dark',
      isMobile: false
    }
  },
  created () {
    this.menus = asyncRouterMap.find(item => item.path === '/').children
  },
  methods: {
    handleMediaQuery (query) {
      this.query = query
      if (this.isMobile && !query['screen-xs']) {
        this.isMobile = false
        return
      }
      if (!this.isMobile && query['screen-xs']) {
        this.isMobile = true
        this.collapsed = false
      }
    },
    handleCollapse (collapsed) {
      this.collapsed = collapsed
    }
  },
  components: {
  	SettingDrawer
  }
}
</script>

API

ProLayout

PropertyDescriptionTypeDefault Value
titlelayout in the upper left corner titleVNode | String'Ant Design Pro'
logolayout top left logo urlVNode | render-
loading*layout loading statusboolean-
layoutlayout menu mode, sidemenu: right navigation, topmenu: top navigation'sidemenu' | 'topmenu''sidemenu'
contentWidthcontent mode of layout, Fluid: adaptive, Fixed: fixed width 1200px'Fixed' | 'Fluid'Fluid
themeNavigation menu theme'light' | 'dark''dark'
menusVue-router routes propObject[{}]
collapsedcontrol menu's collapse and expansionbooleantrue
isMobileis mobilebooleanfalse
handleCollapsefolding collapse event of menu(collapsed: boolean) => void-
menuHeaderRenderrender logo and titlev-slot | VNode | (logo,title)=>VNode | false-
headerRendercustom header render method(props: BasicLayoutProps) => VNode-
rightContentRenderheader right content render method(props: HeaderViewProps) => VNode-
collapsedButtonRendercustom collapsed button method(collapsed: boolean) => VNode-
footerRendercustom footer render method(props: BasicLayoutProps) => VNodefalse
breadcrumbRendercustom breadcrumb render method({ route, params, routes, paths, h }) => VNode[]-
i18nRenderi18nFunction (key: string) => string | falsefalse
handleMediaQuerymedia matchs callback(querys: []) => void-
mediaQuerymedia matchsArray-
openOnceKeymenu only open root keytrue-

PageHeaderWrapper

PropertyDescriptionTypeDefault Value
contentContent areaVNode | v-slot-
extraExtra content area, on the right side of contentVNode | v-slot-
extraContentExtra content area, on the right side of contentVNode | v-slot-
tabListTabs title listArray<{key: string, tab: sting}>-
tab-changeSwitch panel callback(key) => void-
tab-active-keyThe currently highlighted tab itemstring-

SettingDrawer

{settings}

PropertyDescriptionTypeDefault Value
themeThemedark light realDarklight
layoutSider Layoutsidemenu topmenusidemenu
primaryColorPrimary color (*development only)#1890ff
contentWidthcontent mode of layout, Fluid: adaptive, Fixed: fixed width 1200px'Fixed' | 'Fluid'Fluid