首页 > 解决方案 > 反应路由器错误

问题描述

我没有尽头。我的反应路线有问题......现在,我正在加载我的专辑的显示页面(AlbumPage)和索引页面(AlbumPane)......一个人要做什么才能让路线正常工作?

const App = () => (
  <div>
    <AuthRoute exact path="/" component={OfflineHeaderContainer} />
    <AuthRoute exact path="/signup" component={OfflineHeaderContainer} />
    <AuthRoute exact path="/login" component={OfflineHeaderContainer} />
    <AuthRoute path="/" component={Splash} />
    <Route exact path="/home" component={Index}/>
    <Switch>
      <ProtectedRoute exact path="/photos/create" component={Create} />
      <Route path="/photos/:photoID" component={Show} />
      <Route exact path="/albums/:albumID" component={AlbumPage} />
    </Switch>
    <Route path="/albums" componen={AlbumPane} />
    <Route exact path="/users/:userID" component={UserProfileContainer} />
  </div>
);

标签: reactjsroutesrouter

解决方案


看起来你有一些错别字,改变这个:

<Route path="/albums" componen={AlbumPane} />

对此:

<Route exact path="/albums" component={AlbumPane} />

然后你只会在有条件地请求时加载你想要的路线albumID


推荐阅读