【问题标题】:react-router / works well but others can't turn component that's 404react-router / 运行良好,但其他人无法打开 404 组件
【发布时间】:2018-09-23 15:14:40
【问题描述】:

当我使用react router时,只有root router的组件可以正常显示,其他错误router会改变但页面不能出现,主要代码:

    render(<Router history={hashHistory}>
    <Main>
        <Route path='/' component={Menu}/>
        <Route path='/graduationRequirements' component= 
            {GraduationRequirements}/>
        <Route path='/examinationPlan' component={ExaminationPlan}/>
    </Main>
   </Router> , document.getElementById("content"));

当我打开 localhost:3000 就可以了:

enter image description here

但是当我打开 localhost:3000/graduationRequirements 时,它不能出现 GraduationRequirements 组件的页面

【问题讨论】:

标签: reactjs react-router


【解决方案1】:

不知道我的回答对你有没有帮助。字节尝试把这个:

<Route exact path='/' component={Menu}/>

没有这个 React 认为其他路径使用 component={Menu}

【讨论】:

    猜你喜欢
    • 2016-10-05
    • 1970-01-01
    • 2022-10-11
    • 2018-12-05
    • 2023-04-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-12
    相关资源
    最近更新 更多