I am getting the 404 error page when I navigate to a page saying that there is no page with this URL until I refresh the browser the page then shows.
当我导航到一个页面时,我得到了404错误页面,该页面说,在我刷新浏览器之前,没有包含此URL的页面,然后该页面才会显示。
I tried using @reach/router to navigate instead of react-router-dom so now the navigation works but this error keeps coming. I restarted the app few times, the navigation works perfectly at first then this error starts to occur.
我尝试使用@REACH/ROUTER来导航,而不是使用REACT-ROUTER-DOM,所以现在导航可以工作了,但这个错误总是出现。我重新启动了几次应用程序,导航一开始工作得很好,然后开始出现这个错误。
更多回答
优秀答案推荐
The problem is that you are using a different library for routing, which is not the case when working with Gatsby. The way Gatsby works is that you need to create a .js
file inside a pages folder, and it will automatically become a route.
问题是您正在使用不同的库进行路由,但在使用Gatsby时情况并非如此。Gatsby的工作方式是,您需要在Pages文件夹中创建一个.js文件,它将自动成为一条路径。
If you want your page rendered at <host-name>/HelloWorld, then you need to make a file in pages named
HelloWorld.js.`
如果希望在
/HelloWorld中呈现页面,则需要在名为HelloWorld.js.`的页面中创建一个文件。
更多回答
我是一名优秀的程序员,十分优秀!