• Welcome to Journal web site.

我是 PHP 程序员

- 开发无止境 -

Next
Prev

AntDesignVue3 布局

Data: 2018-06-11 23:07:06Form: JournalClick: 0

# 布局


# 一、Layout 布局

组件描述标签
Layout布局容器,其下可嵌套 Header Sider Content Footer 或 Layout 本身,可以放在任何父容器中。<a-layout>
Header顶部布局,自带默认样式,其下可嵌套任何元素,只能放在 Layout 中。<a-layout-header>
Sider侧边栏,自带默认样式及基本功能,其下可嵌套任何元素,只能放在 Layout 中。<a-layout-sider>
Content内容部分,自带默认样式,其下可嵌套任何元素,只能放在 Layout 中。<a-layout-content>
Footer底部布局,自带默认样式,其下可嵌套任何元素,只能放在 Layout 中。<a-layout-footer>
参数描述类型默认值
class容器 classstring
style指定样式object
hasSider表示子元素里有 Sider,一般不用指定。可用于服务端渲染时避免样式闪动boolean
侧边栏 参数描述类型默认值
class容器 classstring
style指定样式object
width宽度number、string200
theme主题颜色light、darkdark
collapsible是否可收起booleanfalse
collapsed(v-model)当前收起状态booleanfalse
<template>
    # 1、a-layout 布局容器,其下可嵌套 Header Sider Content Footer 或 Layout 本身,可以放在任何父容器中。
    <a-layout>
            # 2、a-layout-header 顶部布局,自带默认样式,其下可嵌套任何元素,只能放在 Layout 中。
        <a-layout-header>Header</a-layout-header>
            # 3、a-layout-content 内容部分,自带默认样式,其下可嵌套任何元素,只能放在 Layout 中。
        <a-layout-content>Content</a-layout-content>
            # 4、a-layout-footer 底部布局,自带默认样式,其下可嵌套任何元素,只能放在 Layout 中。
        <a-layout-footer>Footer</a-layout-footer>
    </a-layout>
    <a-layout>
        <a-layout-header>Header</a-layout-header>
        <a-layout>
            # 5、a-layout-sider 侧边栏,自带默认样式及基本功能,其下可嵌套任何元素,只能放在 Layout 中。
            <a-layout-sider>Sider</a-layout-sider>
            <a-layout-content>Content</a-layout-content>
        </a-layout>
        <a-layout-footer>Footer</a-layout-footer>
    </a-layout>
    # 6、style 指定样式
    <a-layout style="width: 500px">
        <a-layout-header :style="{width:'200px'}">Header</a-layout-header>
        <a-layout>
            <a-layout-sider>Sider</a-layout-sider>
            <a-layout-content>Content</a-layout-content>
        </a-layout>
        <a-layout-footer>Footer</a-layout-footer>
    </a-layout>
</template>

# 二、侧边布局

<template>
    # 1、1vh等于视口高度的1%
    <a-layout style="min-height: 100vh">
        # 2、collapsed 当前收起状态
        # 2.1、collapsible 是否可收起
        <a-layout-sider v-model:collapsed="collapsed" collapsible>
            # 3、logo
            <div class="logo" />
            # 4、a-menu 导航菜单
            # 4.1、selectedKeys 当前选中的菜单项 key 数组
            # 4.2、theme 主题颜色
            # 4.3、mode 菜单类型,现在支持垂直、水平、和内嵌模式三种
            <a-menu v-model:selectedKeys="selectedKeys" theme="dark" mode="inline">
                <a-menu-item key="1">
                    <pie-chart-outlined />
                    <span>Option 1</span>
                </a-menu-item>
                <a-menu-item key="2">
                    <desktop-outlined />
                    <span>Option 2</span>
                </a-menu-item>
                <a-sub-menu key="sub1">
                    <template #title>
                        <span>
                            <user-outlined />
                            <span>User</span>
                        </span>
                    </template>
                    <a-menu-item key="3">Tom</a-menu-item>
                    <a-menu-item key="4">Bill</a-menu-item>
                    <a-menu-item key="5">Alex</a-menu-item>
                </a-sub-menu>
                <a-sub-menu key="sub2">
                    <template #title>
                        <span>
                            <team-outlined />
                            <span>Team</span>
                        </span>
                    </template>
                    <a-menu-item key="6">Team 1</a-menu-item>
                    <a-menu-item key="8">Team 2</a-menu-item>
                </a-sub-menu>
                <a-menu-item key="9">
                    <file-outlined />
                    <span>File</span>
                </a-menu-item>
            </a-menu>
        </a-layout-sider>
        <a-layout>
            <a-layout-header style="background: #fff; padding: 0" />
            <a-layout-content style="margin: 0 16px">
              # 5、a-breadcrumb 面包屑
              <a-breadcrumb style="margin: 16px 0">
                  <a-breadcrumb-item>User</a-breadcrumb-item>
                  <a-breadcrumb-item>Bill</a-breadcrumb-item>
              </a-breadcrumb>
              <div :style="{ padding: '24px', background: '#fff', minHeight: '360px' }">
                    Bill is a cat.
              </div>
            </a-layout-content>
            <a-layout-footer style="text-align: center">
                Ant Design ©2018 Created by Ant UED
            </a-layout-footer>
        </a-layout>
    </a-layout>
</template>
<script>
import {
    PieChartOutlined,
    DesktopOutlined,
    UserOutlined,
    TeamOutlined,
    FileOutlined,
} from "@ant-design/icons-vue";
import { defineComponent, ref } from "vue";
export default defineComponent({
    components: {
        PieChartOutlined,
        DesktopOutlined,
        UserOutlined,
        TeamOutlined,
        FileOutlined,
    },
    data() {
        return {
            collapsed: ref(false),
            selectedKeys: ref(["1"]),
        };
    }
});
</script>
<style>
/* #components-layout-demo-side 要去掉,才能看到logo */
#components-layout-demo-side .logo {
    height: 32px;
    margin: 16px;
    background: rgba(255, 255, 255, 0.3);
}

.site-layout .site-layout-background {
    background: #fff;
}
[data-theme="dark"] .site-layout .site-layout-background {
    background: #141414;
}
</style>
Name:
<提交>