如何在服务器上配置路由?

时间:2020-06-04 19:34:49

标签: javascript reactjs react-redux react-router react-router-dom

使用react-router-dom进行路由。在本地服务器上一切正常,但是当我将项目放在主机上时,路由正在工作,但是更新页面后,我看到404错误。告诉我如何在服务器上配置路由,以便它们起作用。我有一个关于React-Redux的项目。非常感谢! 路线

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="div1">
  First Div
</div>
<div id="div2" style="display: none;">
  Second Div
</div>
<button id="btnDisplay">Display</button>

webpack.config

    <Switch>
        <Route exact path='/' component={Home} />
        <Route path='/firstPage' component={FirstPage} />
        <Route path='/secondPage' component={SecondPage} />
        <Route path='/thirdPage' component={ThirdPage} />
    </Switch>

0 个答案:

没有答案