English 中文(简体)
贴切的“/”页线没有要素
原标题:Matched leaf route at location "/" does not have an element

在“/”地点搭配的切叶线没有元素。 这意味着,如果出现导致“豁免”页的违约,就会使该页失去价值。

//App.js File

import { BrowserRouter as Router, Routes, Route } from  react-router-dom ;
import Home from  ./pages/Home ;
// import ReactDOM from "react-dom";


const App = () => {
  return (

    <Router >
      <Routes>

        <Route path="/" component={ Home }></Route>
      </Routes>
    </Router>


  )
}

export default App;

www.un.org/Depts/DGACM/index_spanish.htm 我任何与反应堆有关的代码,如果一开始在方案中插入某些路线,就不知道为何出现这种错误。

问题回答

在V6中,你可以再使用<代码>component。 改为<代码>element:

<Route path="/" element={<Home />}></Route>

https://github.com/remix-run/react-router/blob/main/docs/upgrad/v5.md#advantages-of-route-element”rel=“noreferer”>migration doc

I had the same problem. Replace component with element and it worked.

改为:

<Route path="/" component={HomePage} exact />

为此:

<Route path="/" element={<HomePage/>} exact />

I had the same error however my fix was slightly different I had spelled element wrong.

<Route exact path= /MyGames  element={<MyGames/>}/>

这是它给我留下的青 the的错误。

<编码> 位于“MyGames”地点的相匹配的传单路线没有要素。 这意味着,它将使“Outlet />”变得“无效”,因违约而失去价值,造成“豁免”页。

Very simple:

  1. use element instead of component
  2. wrap the your component like this: {<Home/>} instead of {Home}
<Route path="/" component={ <Home/> } />

<Route path= /about  component={About} />

I used

<Route path= /about  element={<About />} />

解决我的问题,现在进行罚款。

This is a common problem if you are using react-router-dom V6 in your react app. To solve this it s simple

In your code Replace component with element Replace {home} with {<home/>}

This becomes... <Route path="/" element={<Home/>}></Route>

这将明确解决这个问题。

如果你重新使用反应路线6或6或以上,你可能会有包括母子和子女路线在内的通道。 之后,您可尝试开辟一条道路,如一条路线。

/portal

由于该构成部分与儿童路线相对应,因此出现这一错误

/:customerid/portal

但是,你没有读过你的道路(及其儿童路线),足以看到这一点。

For those who have reached this point while using a Route where you don t need an element, in my case, I opted to include a solitary "element".

<Routes>
    <Route exact path="/" element />
    <Route path="/about" element={<About />} />
</Routes>

就我而言,我需要一个路线项目,但确实需要它接收一个要素,因为我使用的道路只是同一个接口的 anchor子。 我不需要装载一个部件。





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签