【发布时间】:2020-04-26 03:02:12
【问题描述】:
我目前正在使用 Gatsby 和 @reach/router
我想将我的关于页面链接到“/profile”
我的路由器看起来像:
<Router>
<Home path="/" />
<About path="/profile" />
<Blog path="/blog" />
<Contact path="/contact" />
</Router>
为什么我的关于页面显示在“/about”而不是“/profile”上?
另外,你把你的路由器组件放在哪里?目前,上面的代码是我的 app.js 文件。这是最佳做法吗?
【问题讨论】:
-
你试过了吗? reach.tech/router/example/basic 将“路径”更改为“到”。
-
Gatsby 使用您的主页名称进行路由。因此,如果您在 Page 文件夹中创建一个名为 about.js 的组件,则会为 /about 创建路由,该路由将为 about 页面提供服务
标签: javascript reactjs web gatsby reach-router