# Container 布局容器
用于布局的容器组件,方便快速搭建页面的基本结构:
<jp-container>
:外层容器。当子元素中包含 <jp-header>
或 <jp-footer>
时,全部子元素会垂直上下排列,否则会水平左右排列。
<jp-header>
:顶栏容器。
<jp-aside>
:侧边栏容器。
<jp-main>
:主要区域容器。
<jp-footer>
:底栏容器。
提示
以上组件采用了 flex 布局,使用前请确定目标浏览器是否兼容。此外,<jp-container>
的子元素只能是后四者,后四者的父元素也只能是 <jp-container>
。
# 常见页面布局
<template>
<div>
<jp-container>
<jp-header>Header</jp-header>
<jp-main>Main</jp-main>
</jp-container>
<jp-container>
<jp-header>Header</jp-header>
<jp-main>Main</jp-main>
<jp-footer>Footer</jp-footer>
</jp-container>
<jp-container>
<jp-aside width="200px">Aside</jp-aside>
<jp-main>Main</jp-main>
</jp-container>
<jp-container>
<jp-header>Header</jp-header>
<jp-container>
<jp-aside width="200px">Aside</jp-aside>
<jp-main>Main</jp-main>
</jp-container>
</jp-container>
<jp-container>
<jp-header>Header</jp-header>
<jp-container>
<jp-aside width="200px">Aside</jp-aside>
<jp-container>
<jp-main>Main</jp-main>
<jp-footer>Footer</jp-footer>
</jp-container>
</jp-container>
</jp-container>
<jp-container>
<jp-aside width="200px">Aside</jp-aside>
<jp-container>
<jp-header>Header</jp-header>
<jp-main>Main</jp-main>
</jp-container>
</jp-container>
<jp-container>
<jp-aside width="200px">Aside</jp-aside>
<jp-container>
<jp-header>Header</jp-header>
<jp-main>Main</jp-main>
<jp-footer>Footer</jp-footer>
</jp-container>
</jp-container>
</div>
</template>
<style scoped>
.jp-header,
.jp-footer {
background-color: #b3c0d1;
color: #333;
text-align: center;
line-height: 60px;
}
.jp-aside {
background-color: #d3dce6;
color: #333;
text-align: center;
line-height: 200px;
}
.jp-main {
background-color: #e9eef3;
color: #333;
text-align: center;
line-height: 160px;
}
body > .jp-container {
margin-bottom: 40px;
}
.jp-container:nth-child(5) .jp-aside,
.jp-container:nth-child(6) .jp-aside {
line-height: 260px;
}
.jp-container:nth-child(7) .jp-aside {
line-height: 320px;
}
</style>
显示代码
# 实例
- 查看
- 新增
- 删除
<template>
<jp-container style="height: 500px; border: 1px solid #eee">
<jp-aside width="200px" style="background-color: rgb(238, 241, 246)">
<jp-menu :default-openeds="['1', '3']">
<jp-submenu index="1">
<template slot="title">
<i class="jp-icon-message"></i>
导航一
</template>
<jp-menu-item-group>
<template slot="title">分组一</template>
<jp-menu-item index="1-1">选项1</jp-menu-item>
<jp-menu-item index="1-2">选项2</jp-menu-item>
</jp-menu-item-group>
<jp-menu-item-group title="分组2">
<jp-menu-item index="1-3">选项3</jp-menu-item>
</jp-menu-item-group>
<jp-submenu index="1-4">
<template slot="title">选项4</template>
<jp-menu-item index="1-4-1">选项4-1</jp-menu-item>
</jp-submenu>
</jp-submenu>
<jp-submenu index="2">
<template slot="title">
<i class="jp-icon-menu"></i>
导航二
</template>
<jp-menu-item-group>
<template slot="title">分组一</template>
<jp-menu-item index="2-1">选项1</jp-menu-item>
<jp-menu-item index="2-2">选项2</jp-menu-item>
</jp-menu-item-group>
<jp-menu-item-group title="分组2">
<jp-menu-item index="2-3">选项3</jp-menu-item>
</jp-menu-item-group>
<jp-submenu index="2-4">
<template slot="title">选项4</template>
<jp-menu-item index="2-4-1">选项4-1</jp-menu-item>
</jp-submenu>
</jp-submenu>
<jp-submenu index="3">
<template slot="title">
<i class="jp-icon-setting"></i>
导航三
</template>
<jp-menu-item-group>
<template slot="title">分组一</template>
<jp-menu-item index="3-1">选项1</jp-menu-item>
<jp-menu-item index="3-2">选项2</jp-menu-item>
</jp-menu-item-group>
<jp-menu-item-group title="分组2">
<jp-menu-item index="3-3">选项3</jp-menu-item>
</jp-menu-item-group>
<jp-submenu index="3-4">
<template slot="title">选项4</template>
<jp-menu-item index="3-4-1">选项4-1</jp-menu-item>
</jp-submenu>
</jp-submenu>
</jp-menu>
</jp-aside>
<jp-container>
<jp-header style="text-align: right; font-size: 12px">
<jp-dropdown>
<i class="jp-icon-setting" style="margin-right: 15px"></i>
<jp-dropdown-menu slot="dropdown">
<jp-dropdown-item>查看</jp-dropdown-item>
<jp-dropdown-item>新增</jp-dropdown-item>
<jp-dropdown-item>删除</jp-dropdown-item>
</jp-dropdown-menu>
</jp-dropdown>
<span>王小虎</span>
</jp-header>
<jp-main>
<jp-table :data="tableData">
<jp-table-column prop="date" label="日期" width="140"></jp-table-column>
<jp-table-column prop="name" label="姓名" width="120"></jp-table-column>
<jp-table-column prop="address" label="地址"></jp-table-column>
</jp-table>
</jp-main>
</jp-container>
</jp-container>
</template>
<style scoped>
.jp-header {
background-color: #b3c0d1;
color: #333;
line-height: 60px;
}
.jp-aside {
color: #333;
}
</style>
<script>
export default {
data() {
const item = {
date: '2016-05-02',
name: '王小虎',
address: '上海市普陀区金沙江路 1518 弄'
}
return {
tableData: Array(20).fill(item)
}
}
}
</script>
显示代码
# Container Attributes
参数 | 说明 | 类型 | 可选值 | 默认值 |
---|---|---|---|---|
direction | 子元素的排列方向 | string | horizontal / vertical | 子元素中有 jp-header 或 jp-footer 时为 vertical,否则为 horizontal |
# Header Attributes
参数 | 说明 | 类型 | 可选值 | 默认值 |
---|---|---|---|---|
height | 顶栏高度 | string | — | 60px |
# Aside Attributes
参数 | 说明 | 类型 | 可选值 | 默认值 |
---|---|---|---|---|
width | 侧边栏宽度 | string | — | 300px |
# Footer Attributes
参数 | 说明 | 类型 | 可选值 | 默认值 |
---|---|---|---|---|
height | 底栏高度 | string | — | 60px |