2017-02-27 23:39:16 +08:00
|
|
|
---
|
|
|
|
order: 2
|
|
|
|
title:
|
|
|
|
zh-CN: 顶部-侧边布局-通栏
|
|
|
|
en-US: Header Sider 2
|
|
|
|
---
|
|
|
|
|
|
|
|
## zh-CN
|
|
|
|
|
|
|
|
同样拥有顶部导航及侧边栏,区别是两边未留边距,多用于应用型的网站。
|
|
|
|
|
|
|
|
## en-US
|
|
|
|
|
|
|
|
Both the top navigation and the sidebar, commonly used in application site.
|
|
|
|
|
2022-03-18 15:20:35 +08:00
|
|
|
```tsx
|
2022-05-23 14:37:16 +08:00
|
|
|
import { LaptopOutlined, NotificationOutlined, UserOutlined } from '@ant-design/icons';
|
2022-05-07 14:31:54 +08:00
|
|
|
import type { MenuProps } from 'antd';
|
2022-05-23 14:37:16 +08:00
|
|
|
import { Breadcrumb, Layout, Menu } from 'antd';
|
|
|
|
import React from 'react';
|
2018-06-27 15:55:04 +08:00
|
|
|
|
2017-02-27 23:39:16 +08:00
|
|
|
const { Header, Content, Sider } = Layout;
|
|
|
|
|
2022-03-18 15:20:35 +08:00
|
|
|
const items1: MenuProps['items'] = ['1', '2', '3'].map(key => ({
|
|
|
|
key,
|
|
|
|
label: `nav ${key}`,
|
|
|
|
}));
|
|
|
|
|
|
|
|
const items2: MenuProps['items'] = [UserOutlined, LaptopOutlined, NotificationOutlined].map(
|
|
|
|
(icon, index) => {
|
|
|
|
const key = String(index + 1);
|
|
|
|
|
|
|
|
return {
|
|
|
|
key: `sub${key}`,
|
|
|
|
icon: React.createElement(icon),
|
|
|
|
label: `subnav ${key}`,
|
|
|
|
|
|
|
|
children: new Array(4).fill(null).map((_, j) => {
|
|
|
|
const subKey = index * 4 + j + 1;
|
|
|
|
return {
|
|
|
|
key: subKey,
|
|
|
|
label: `option${subKey}`,
|
|
|
|
};
|
|
|
|
}),
|
|
|
|
};
|
|
|
|
},
|
|
|
|
);
|
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
const App: React.FC = () => (
|
2017-02-27 23:39:16 +08:00
|
|
|
<Layout>
|
|
|
|
<Header className="header">
|
|
|
|
<div className="logo" />
|
2022-03-18 15:20:35 +08:00
|
|
|
<Menu theme="dark" mode="horizontal" defaultSelectedKeys={['2']} items={items1} />
|
2017-02-27 23:39:16 +08:00
|
|
|
</Header>
|
|
|
|
<Layout>
|
2019-12-26 12:21:08 +08:00
|
|
|
<Sider width={200} className="site-layout-background">
|
2017-02-27 23:39:16 +08:00
|
|
|
<Menu
|
|
|
|
mode="inline"
|
|
|
|
defaultSelectedKeys={['1']}
|
|
|
|
defaultOpenKeys={['sub1']}
|
2017-06-15 15:39:55 +08:00
|
|
|
style={{ height: '100%', borderRight: 0 }}
|
2022-03-18 15:20:35 +08:00
|
|
|
items={items2}
|
|
|
|
/>
|
2017-02-27 23:39:16 +08:00
|
|
|
</Sider>
|
|
|
|
<Layout style={{ padding: '0 24px 24px' }}>
|
2017-10-16 20:39:53 +08:00
|
|
|
<Breadcrumb style={{ margin: '16px 0' }}>
|
2017-02-27 23:39:16 +08:00
|
|
|
<Breadcrumb.Item>Home</Breadcrumb.Item>
|
|
|
|
<Breadcrumb.Item>List</Breadcrumb.Item>
|
|
|
|
<Breadcrumb.Item>App</Breadcrumb.Item>
|
|
|
|
</Breadcrumb>
|
2019-05-07 14:57:32 +08:00
|
|
|
<Content
|
2019-12-26 12:21:08 +08:00
|
|
|
className="site-layout-background"
|
2019-05-07 14:57:32 +08:00
|
|
|
style={{
|
|
|
|
padding: 24,
|
|
|
|
margin: 0,
|
|
|
|
minHeight: 280,
|
|
|
|
}}
|
2018-11-28 15:00:03 +08:00
|
|
|
>
|
2017-02-27 23:39:16 +08:00
|
|
|
Content
|
|
|
|
</Content>
|
|
|
|
</Layout>
|
|
|
|
</Layout>
|
2022-04-03 23:27:45 +08:00
|
|
|
</Layout>
|
2018-11-28 15:00:03 +08:00
|
|
|
);
|
2022-05-19 09:46:26 +08:00
|
|
|
|
|
|
|
export default App;
|
2019-05-07 14:57:32 +08:00
|
|
|
```
|
2017-02-27 23:39:16 +08:00
|
|
|
|
2019-05-07 14:57:32 +08:00
|
|
|
```css
|
2017-02-27 23:39:16 +08:00
|
|
|
#components-layout-demo-top-side-2 .logo {
|
2020-10-26 12:17:07 +08:00
|
|
|
float: left;
|
2017-02-27 23:39:16 +08:00
|
|
|
width: 120px;
|
|
|
|
height: 31px;
|
2020-10-26 12:17:07 +08:00
|
|
|
margin: 16px 24px 16px 0;
|
|
|
|
background: rgba(255, 255, 255, 0.3);
|
|
|
|
}
|
|
|
|
|
|
|
|
.ant-row-rtl #components-layout-demo-top-side-2 .logo {
|
|
|
|
float: right;
|
|
|
|
margin: 16px 0 16px 24px;
|
2017-02-27 23:39:16 +08:00
|
|
|
}
|
2019-12-26 12:21:08 +08:00
|
|
|
|
|
|
|
.site-layout-background {
|
|
|
|
background: #fff;
|
|
|
|
}
|
2019-05-07 14:57:32 +08:00
|
|
|
```
|