繁体   English   中英

为什么反应路由不能直接在浏览器中工作?

[英]Why does react-routing not work directly in the browser?

我在通用反应应用程序中使用react-router 2.0。 通过链接组件的导航有效,但是当我手动粘贴url时,没有任何反应(浏览器挂起)。 如何解决此问题? 这是路由器代码:

<Route path="/" component={App}>
  { /* Home (main) route */ }
  <IndexRoute component={Home}/>

  { /* Routes requiring login */ }
  <Route onEnter={requireLogin}>
    <Route path="chat" component={Chat}/>
    <Route path="loginSuccess" component={LoginSuccess}/>
  </Route>

  { /* Routes */ }
  <Route path="about" component={About}/>
  <Route path="login" component={Login}/>
  <Route path="pagination" component={Pagination}/>
  <Route path="survey/:user" component={Survey}/>
  <Route path="widgets" component={Widgets}/>
  <Route path="search" component={Search}/>
  <Route path="make/model/:id" component={Details}/>
  { /* Catch all route */ }
  <Route path="*" component={NotFound} status={404} />
</Route>

在您的路线上尝试

在所有这样的路由中添加“ /”

<Route path="/about" component={About}/>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM