|
|
@@ -1,9 +1,8 @@
|
|
|
import React, { Component } from "react";
|
|
|
-import { Route, Switch } from "react-router-dom";
|
|
|
+import { Route, Switch, Link, withRouter} from "react-router-dom";
|
|
|
import Overview from "../../components/Overview/overview";
|
|
|
import Stocks from "../../components/StocksApi/stocks";
|
|
|
import indexBasicInfo from "../../components/indexBasicInfo/indexBasicInfo";
|
|
|
-import { Link } from "react-router-dom";
|
|
|
import stocksApiList from "../../StocksApiList";
|
|
|
import indexApiList from "../../IndexApiList";
|
|
|
import "antd/dist/antd.css";
|
|
|
@@ -16,7 +15,7 @@ import {
|
|
|
} from "@ant-design/icons";
|
|
|
const { SubMenu } = Menu;
|
|
|
const { Header, Content, Sider } = Layout;
|
|
|
-export default class NavBar extends Component {
|
|
|
+class NavBar extends Component {
|
|
|
constructor(props) {
|
|
|
super(props);
|
|
|
this.state = {
|
|
|
@@ -25,6 +24,10 @@ export default class NavBar extends Component {
|
|
|
}
|
|
|
render() {
|
|
|
// let { match } = this.props;
|
|
|
+ const pathNames = this.props.history.location.pathname;
|
|
|
+ let defaultS = [];
|
|
|
+ defaultS.push(pathNames);
|
|
|
+ console.log(defaultS)//实时根据当前路径更新
|
|
|
return (
|
|
|
<Layout style={{ minHeight: "100vh" }}>
|
|
|
<Header className="header">BoNiu</Header>
|
|
|
@@ -35,6 +38,7 @@ export default class NavBar extends Component {
|
|
|
defaultSelectedKeys={["overview"]}
|
|
|
defaultOpenKeys={["overview"]}
|
|
|
style={{ height: "100%", borderRight: 0 }}
|
|
|
+ selectedKeys={pathNames}
|
|
|
>
|
|
|
<Menu.Item key="overview" icon={<UserOutlined />}>
|
|
|
<Link to="/overview">总体说明</Link>
|
|
|
@@ -89,3 +93,5 @@ export default class NavBar extends Component {
|
|
|
);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+export default withRouter(NavBar)
|