Commit 2c763479 authored by chencheng's avatar chencheng

6. Add layout

parent ee9ccba3
import { Menu, Icon } from 'antd';
import Link from 'umi/link';
function Header({ location }) {
return (
<Menu
selectedKeys={[location.pathname]}
mode="horizontal"
theme="dark"
>
<Menu.Item key="/">
<Link to="/"><Icon type="home" />Home</Link>
</Menu.Item>
<Menu.Item key="/users">
<Link to="/users"><Icon type="bars" />Users</Link>
</Menu.Item>
<Menu.Item key="/umi">
<a href="https://github.com/umijs/umi" target="_blank">umi</a>
</Menu.Item>
<Menu.Item key="/dva">
<a href="https://github.com/dvajs/dva" target="_blank">dva</a>
</Menu.Item>
<Menu.Item key="/404">
<Link to="/page-you-dont-know"><Icon type="frown-circle" />404</Link>
</Menu.Item>
</Menu>
);
}
export default Header;
.normal {
display: flex;
flex-direction: column;
height: 100%;
}
.content {
flex: 1;
display: flex;
}
.main {
padding: 0 8px;
flex: 1 0 auto;
}
import React from 'react';
import styles from './index.css';
import Header from './Header';
import withRouter from 'umi/withRouter';
function Layout({ children, location }) {
return (
<div className={styles.normal}>
<Header location={location} />
<div className={styles.content}>
<div className={styles.main}>
{children}
</div>
</div>
</div>
);
}
export default withRouter(Layout);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment