为什么react-routing不能直接在浏览器中运行?

时间:2017-07-05 07:29:21

标签: javascript reactjs react-router react-universal

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

<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>

1 个答案:

答案 0 :(得分:-1)

在你的路线中尝试这个

在所有路线中添加“/”,如此

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