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

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

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    react router4.0路由嵌套
    19
    0

    先上代码为敬

    
    const routes = [
        {
            path: '/',
            exact: true,
            component: Main,
        },
        {
            path: '/company',
            // exact: true,
            component: CompanyIntroduce,
            routes:[
                {
                    path: '/company/introduce',
                    exact: true,
                    component: CompanyManagement,
                },
                {
                    path: '/company/management',
                    exact: true,
                    component: CompanyManagement,
                },
            ]
        },
    ];
    
    const router = (
        <Router history={history}>
            <AppContainer history={history}>
                <Switch>
                    {routes.map((route, i) => (
                        <ExtendRoute key={i} {...route} />
                    ))}
                    <Route component={NoMatchContainer} />
                </Switch>
            </AppContainer>
        </Router>
    );
    
    export default router;
    

    想做一个嵌套路由,访问/company/company/introduce都指向CompanyIntroduce 组件,而访问/company/management指向CompanyManagement 组件,可是事实结果就是不管我,访问/company也好,访问/company/introduce也好,还是访问/company/management也好,通通指向到CompanyIntroduce 组件,react router4.0版本已经看了 两三天了,愣是没看懂它的用法,和vue的路由比较起来,真的是难用难理解,求会的大佬帮忙看一下问题在哪,不胜感激!!

    0
    打赏
    收藏
    点击回答
        全部回答
    • 0
    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部