下面是首页路由的配置class RouterMap extends React.Component { render() { return (<BrowserRouter><div> <Switch> <Route path='/' exact component={Home}/> <Route path="/users" component={Users}/> <Route path='/city' component={City}/> <Route path='/city2' component={City2}/> <Route path='/result' component={Result}/> <Route match='match' path='/dashboard' exact component={Dashboard}/> <Route path='/dashboard/id' component={Dashboard200}/> </Switch> </div></BrowserRouter>) }}下面是子路由页面的配置class Dashboard extends React.Component { componentDidMount(){ //console.log(this.props) } render() { console.log(this.props) const match=this.props.match return (<div> <div>123</div> <Switch> <Route path={`${match.url}/2`} component={Dashboard6}/> <Route path={`${match.url}/3`} component={Dashboard1}/> <Route path="/2" component={Dashboard1}/> </Switch> </div>) }}
添加回答
举报
0/150
提交
取消