import React, { Component } from "react";
import { withRouter } from "react-router-dom";
import "./index.scss";
const navbarMap = {
    "/login": "用户登录",
    "/information": "用户信息录入",
    '/admin' :'管理员中心',
    '/admin/login':'管理员登录'
};
class Navbar extends Component {
    state = {
        title: navbarMap[this.props.location.pathname]
    };
    constructor(props) {
        super(props);
        props.history.listen(location => {
            //在这里监听location对象
            let { pathname } = location;
            this.setState({ title: navbarMap[pathname] });
        });
    }
    render() {
        return (
            <nav className="page-nav">
                <i className="nav-logo" />
                <div className="nav-title">{this.state.title}</div>
            </nav>
        );
    }
}

export default withRouter(Navbar);
