Skip to content

Container 布局容器

用于布局的容器组件,方便快速搭建页面的基本结构:

<v-container>:外层容器。

<v-header>:顶栏容器。

<v-aside>:侧边栏容器。

<v-main>:主要区域容器。

<v-footer>:底栏容器。

常见页面布局

Header
Main

<template>
  <div class="layout">
    <v-container vertical>
      <v-header>Header</v-header>
      <v-main>Main</v-main>
    </v-container>
  </div>
</template>
<style scoped lang="scss">
.layout {
  .v-header,
  .v-main {
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .v-header {
    background-color: var(--v-color-primary-light-7);
    color: var(--v-text-color-primary);
    text-align: center;
  }

  .v-main {
    background-color: var(--v-color-primary-light-9);
    color: var(--v-text-color-primary);
    text-align: center;
    height: 150px;
  }
}
</style>

Header
Main
Footer

<template>
  <div class="layout">
    <v-container vertical>
      <v-header>Header</v-header>
      <v-main>Main</v-main>
      <v-footer>Footer</v-footer>
    </v-container>
  </div>
</template>
<style scoped lang="scss">
.layout {
  .v-header,
  .v-footer,
  .v-main {
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .v-header,
  .v-footer {
    background-color: var(--v-color-primary-light-7);
    color: var(--v-text-color-primary);
    text-align: center;
  }

  .v-main {
    background-color: var(--v-color-primary-light-9);
    color: var(--v-text-color-primary);
    text-align: center;
    height: 150px;
  }
}
</style>

Main

<template>
  <div class="layout">
    <v-container>
      <v-aside width="200px">Aside</v-aside>
      <v-main>Main</v-main>
      <v-aside width="200px">Aside</v-aside>
    </v-container>
  </div>
</template>
<style scoped lang="scss">
.layout {
  .v-main,
  .v-aside {
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .v-main {
    background-color: var(--v-color-primary-light-9);
    color: var(--v-text-color-primary);
    text-align: center;
    height: 150px;
  }

  .v-aside {
    background-color: var(--v-color-primary-light-8);
    color: var(--v-text-color-primary);
    text-align: center;
  }
}
</style>

Header
Main

<template>
  <div class="layout">
    <v-container vertical>
      <v-header>Header</v-header>
      <v-container>
        <v-aside width="200px">Aside</v-aside>
        <v-main>Main</v-main>
      </v-container>
    </v-container>
  </div>
</template>
<style scoped lang="scss">
.layout {
  .v-main,
  .v-aside,
  .v-header {
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .v-main {
    background-color: var(--v-color-primary-light-9);
    color: var(--v-text-color-primary);
    text-align: center;
    height: 150px;
  }

  .v-aside {
    background-color: var(--v-color-primary-light-8);
    color: var(--v-text-color-primary);
    text-align: center;
  }

  .v-header {
    background-color: var(--v-color-primary-light-7);
    color: var(--v-text-color-primary);
    text-align: center;
  }
}
</style>

Header
Main
Footer

<template>
  <div class="layout">
    <v-container vertical>
      <v-header>Header</v-header>
      <v-container>
        <v-aside width="200px">Aside</v-aside>
        <v-container vertical>
          <v-main>Main</v-main>
          <v-footer>Footer</v-footer>
        </v-container>
      </v-container>
    </v-container>
  </div>
</template>
<style scoped lang="scss">
.layout {
  .v-main,
  .v-aside,
  .v-header,
  .v-footer {
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .v-main {
    background-color: var(--v-color-primary-light-9);
    color: var(--v-text-color-primary);
    text-align: center;
    height: 150px;
  }

  .v-aside {
    background-color: var(--v-color-primary-light-8);
    color: var(--v-text-color-primary);
    text-align: center;
  }

  .v-header,
  .v-footer {
    background-color: var(--v-color-primary-light-7);
    color: var(--v-text-color-primary);
    text-align: center;
  }
}
</style>

Header
Main

<template>
  <div class="layout">
    <v-container>
      <v-aside width="200px">Aside</v-aside>
      <v-container vertical>
        <v-header>Header</v-header>
        <v-main>Main</v-main>
      </v-container>
    </v-container>
  </div>
</template>
<style scoped lang="scss">
.layout {
  .v-main,
  .v-aside,
  .v-header {
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .v-main {
    background-color: var(--v-color-primary-light-9);
    color: var(--v-text-color-primary);
    text-align: center;
    height: 150px;
  }

  .v-aside {
    background-color: var(--v-color-primary-light-8);
    color: var(--v-text-color-primary);
    text-align: center;
  }

  .v-header {
    background-color: var(--v-color-primary-light-7);
    color: var(--v-text-color-primary);
    text-align: center;
  }
}
</style>

Header
Main
Main

<template>
  <div class="layout">
    <v-container>
      <v-aside width="200px">Aside</v-aside>
      <v-container vertical>
        <v-header>Header</v-header>
        <v-main>Main</v-main>
        <v-footer>Main</v-footer>
      </v-container>
    </v-container>
  </div>
</template>
<style scoped lang="scss">
.layout {
  .v-main,
  .v-aside,
  .v-header,
  .v-footer {
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .v-main {
    background-color: var(--v-color-primary-light-9);
    color: var(--v-text-color-primary);
    text-align: center;
    height: 150px;
  }

  .v-aside {
    background-color: var(--v-color-primary-light-8);
    color: var(--v-text-color-primary);
    text-align: center;
  }

  .v-header,
  .v-footer {
    background-color: var(--v-color-primary-light-7);
    color: var(--v-text-color-primary);
    text-align: center;
  }
}
</style>

Container Attributes

属性名说明类型默认值
vertical是否垂直排列booleanfalse

Container Slots

插槽名说明子标签
default自定义默认内容Container / Header / Aside / Main / Footer

Header Attributes

属性名说明类型默认值
height顶栏高度string60px

Header Slots

插槽名说明
default自定义默认内容

Aside Attributes

属性名说明类型默认值
width侧边栏宽度string300px

Aside Slots

插槽名说明
default自定义默认内容

Main Slots

插槽名说明
default自定义默认内容
属性名说明类型默认值
height底栏高度string60px
插槽名说明
default自定义默认内容