React Router V6尝试将网页链接在一起时显示空白网页

发布于 2025-01-25 02:19:06 字数 285 浏览 2 评论 0原文

我正在尝试遵循YouTube上React UI的Lamadevs Basic Bluat博客教程。在视频的最后一部分中,我无法将我的网页链接到app.js中,因为他使用版本5而不是6版。我尝试将开关切换到路由,但也无法使用。我是否必须下载旧的React Router Router Dom V5才能正常工作?现在,它导致一个空白的网页。

在此处输入图像描述

I am trying to follow lamadevs Basic blog tutorial for the UI in React on youtube. In the last section of the video I am unable to link my webpages together in App.js because he uses version 5 instead of 6. I tried switching the switch to route instead but it also didnt work. Do I have to download the old react router dom v5 for it to work? Right now it results in a blank Webpage.

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

以歌曲疗慰 2025-02-01 02:19:06

所以应该这样:

 <>
  < topbar /> 
    < browserrouter>
    <路线>
      <路由路径=“ /”元素= {< app />}>
      </route>
    </routes>
  </browserrouter>,
</>
 

区别在于,现在您不编写组件,但是元素和元素是JSX,而不是组件函数本身。尝试一下,它应该起作用。

So it should be like this:

<>
  <TopBar /> 
    <BrowserRouter>
    <Routes>
      <Route path="/" element={<App />}>
      </Route>
    </Routes>
  </BrowserRouter>,
</>

The difference is, now you don't write a component, but element and element is a JSX, and not component function itself. Try this, it should work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文