位置“/"处匹配的叶路由没有元素 [英] Matched leaf route at location "/" does not have an element
本文介绍了位置“/"处匹配的叶路由没有元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在位置/"匹配的叶子路由;没有元素.这意味着默认情况下它将使用空值呈现 ,从而导致空"页
Matched leaf route at location "/" does not have an element. This means it will render an with a null value by default resulting in an "empty" page
//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;
**我的任何反应路由器相关代码都不起作用,我不知道为什么当我开始在程序中插入一些路由时会发生这种情况,因此它显示此错误 **
**My any react router related code not working i don't know why it happend when i start insert some route in program so it show this error **
推荐答案
在 V6 中,您不能再使用 component
属性.它被替换为 element
:
In V6, you can't use the component
prop anymore. It was replaced in favor of element
:
<Route path="/" element={<Home />}></Route>
更多信息在 迁移文档.
这篇关于位置“/"处匹配的叶路由没有元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文