账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    react4怎么嵌套路由啊?我的二级路由没有显示,也不报错是怎么回事?
    • ༺ۣۖꪑۣۖ༒ۣꫀۣۖ༻2020-01-01 00:00
    55
    0

    下面是首页路由的配置

    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>)
        }
    }
    1
    打赏
    收藏
    点击回答
        全部回答
    • 0
    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部