我正在使用 react-router 版本 4,因为组件的路由配置已完成,但组件未安装,因为我尝试使用 componentDidMount() 方法,未显示控制台日志。
这是我的代码,
import { Route,Switch,hashHistory } from 'react-router';
import {HashRouter as Router} from 'react-router-dom';
import { createHistory, useBeforeUnload } from 'history';
<Router history={hashHistory}>
<div>
<Route exact path='/userlogin/' component={LoginPage}></Route>
<Route exact path='/dashboard/' component={Dashboard}></Route>
<Route exact path='/forgotpassword/' component={ForgotPasswordPage}></Route>
</div>
</Router>
当我尝试使用组件的路由器 url 路径时,页面为空。
任何帮助表示赞赏。在此先感谢。!