PageLayout 页面布局
该组件是一个页面布局组件,用于快速生成一个页面布局,扩展性强,适合各种场景使用
基础用法
- 1
查看代码
vue
<template>
<gi-page-layout bordered>
<template #tool>
<el-space>
<el-button type="primary">新增</el-button>
<el-button type="primary">导出</el-button>
</el-space>
</template>
<Table></Table>
</gi-page-layout>
</template>
<script setup lang="ts">
import Table from './components/Table.vue'
</script>
<style lang="scss" scoped></style>搜索
- 1
查看代码
vue
<template>
<gi-page-layout bordered>
<template #header>
<Search></Search>
</template>
<Table></Table>
</gi-page-layout>
</template>
<script setup lang="ts">
import Search from '@docs/_components/Search.vue'
import Table from './components/Table.vue'
</script>
<style lang="scss" scoped></style>搜索 + 按钮
- 1
查看代码
vue
<template>
<gi-page-layout bordered>
<template #header>
<Search></Search>
</template>
<template #tool>
<el-space>
<el-button type="primary">新增</el-button>
<el-button type="primary">导出</el-button>
</el-space>
</template>
<Table></Table>
</gi-page-layout>
</template>
<script setup lang="ts">
import Search from '@docs/_components/Search.vue'
import Table from './components/Table.vue'
</script>
<style lang="scss" scoped></style>左侧树
- 1
查看代码
vue
<template>
<gi-page-layout bordered :size="160" :style="{ height: '500px' }">
<template #left>
<Tree></Tree>
</template>
<template #header>
<Search></Search>
</template>
<Table></Table>
</gi-page-layout>
</template>
<script setup lang="ts">
import Search from '@docs/_components/Search.vue'
import Table from '@docs/_components/Table.vue'
import Tree from '@docs/_components/Tree.vue'
</script>
<style lang="scss" scoped></style>布局嵌套布局
选项1
选项2
选项3
- 1
查看代码
vue
<template>
<gi-page-layout bordered :style="{ height: '500px' }" :header-style="{ padding: '8px 0 0', borderBottom: 'none' }"
:body-style="{ padding: 0 }">
<template #header>
<gi-tabs v-model="activeName" :options="options">
<template #extra>
<el-space wrap>
<el-button type="primary">新增</el-button>
<el-button type="danger">删除</el-button>
</el-space>
</template>
</gi-tabs>
</template>
<gi-page-layout :size="150">
<template #left>
<Tree></Tree>
</template>
<Table></Table>
</gi-page-layout>
</gi-page-layout>
</template>
<script setup lang="ts">
import type { TabsOptionItem } from 'gi-component'
import Table from '@docs/_components/Table.vue'
import Tree from '@docs/_components/Tree.vue'
import { ref } from 'vue'
const activeName = ref('1')
const options: TabsOptionItem[] = [
{ label: '选项1', name: '1' },
{ label: '选项2', name: '2' },
{ label: '选项3', name: '3' }
]
</script>API
Props
| 属性名 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| size | 左侧面板宽度/占比 | SplitterPanelProps['size'] | 270 |
| bordered | 是否显示外边框 | boolean | false |
| collapse | 是否可以折叠 | boolean | true |
| leftStyle | 左侧区域自定义样式 | CSSProperties | {} |
| headerStyle | 头部区域自定义样式 | CSSProperties | {} |
| toolStyle | 操作栏区域自定义样式 | CSSProperties | {} |
| bodyStyle | 内容区域自定义样式 | CSSProperties | {} |
Slots
| 名称 | 说明 |
|---|---|
| default | 自定义内容 |
| header | 自定义头部 |
| left | 自定义左侧 |
| tool | 自定义操作栏 |
提示:只有在插槽
left存在时才会渲染可折叠的左侧区域与折叠按钮。若collapse设为false,左侧区域固定展示。
