reactjs - 反应路由器错误
问题描述
我没有尽头。我的反应路线有问题......现在,我正在加载我的专辑的显示页面(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>
);
解决方案
看起来你有一些错别字,改变这个:
<Route path="/albums" componen={AlbumPane} />
对此:
<Route exact path="/albums" component={AlbumPane} />
然后你只会在有条件地请求时加载你想要的路线albumID
推荐阅读
- php - 无法选择包含重音符号的列名
- javascript - JavaScript 中值 0x80000000 的数量是如何组织的?
- swift - Swift 中与其他协议的可解码一致性
- javascript - 在 laravel7 中安装 npm 后如何使用 nouislider
- elasticsearch - 如何在 conf/elasticsearch.yml 中定义 datacenter.group 以运行 Elassandra 多数据中心?
- numerical-methods - 泊松方程数值解过程中的 NAN
- azure - cosmosDB 中 gremlin 查询结果集大小的限制
- javascript - @nuxt/http 在 SSR 期间不会向 API 发送 cookie
- dart - Dart中的int和双重等式与const
- git - 从巨大的 Git 存储库中删除历史记录