-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
86 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import React from 'react'; | ||
import { Menu, Icon } from 'antd'; | ||
import { Link } from 'dva/router'; | ||
|
||
function Header({ location }) { | ||
return ( | ||
<Menu | ||
selectedKeys={[location.pathname]} | ||
mode="horizontal" | ||
theme="dark" | ||
> | ||
<Menu.Item key="/users"> | ||
<Link to="/users"><Icon type="bars" />Users</Link> | ||
</Menu.Item> | ||
<Menu.Item key="/"> | ||
<Link to="/"><Icon type="home" />Home</Link> | ||
</Menu.Item> | ||
<Menu.Item key="/404"> | ||
<Link to="/page-you-dont-know"><Icon type="frown-circle" />404</Link> | ||
</Menu.Item> | ||
<Menu.Item key="/antd"> | ||
<a href="https://github.com/dvajs/dva" target="_blank">dva</a> | ||
</Menu.Item> | ||
</Menu> | ||
); | ||
} | ||
|
||
export default Header; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
.normal { | ||
display: flex; | ||
flex-direction: column; | ||
height: 100%; | ||
} | ||
|
||
.content { | ||
flex: 1; | ||
display: flex; | ||
} | ||
|
||
.main { | ||
padding: 0 8px; | ||
flex: 1 0 auto; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React from 'react'; | ||
import styles from './MainLayout.css'; | ||
import Header from './Header'; | ||
|
||
function MainLayout({ children, location }) { | ||
return ( | ||
<div className={styles.normal}> | ||
<Header location={location} /> | ||
<div className={styles.content}> | ||
<div className={styles.main}> | ||
{children} | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default MainLayout; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
|
||
.normal { | ||
} | ||
|
||
.normal { | ||
width: 900px; | ||
margin: 3em auto 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94788e5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
selectedKeys={[location.pathname]}, 这里的location.pathname是"/",麻烦问下是为什么?
94788e5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Justinnng 我也遇到过,因为编写过程中少一个 location 导致让它变成 window.location.pathname
94788e5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我一直报....
94788e5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
User.js中自己漏写了一个location导致最后出现TypeError: Cannot read property 'pathname' of undefined“”。还是要仔细
94788e5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
94788e5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
每个page引入layout 不是很麻烦吗,放到router下很方便