React 路由器不显示主页和所有其他页面
React router does not show the homepage and all other pages
我有这段代码,但它不显示主页,即位于“/”的页面。但是,如果我在 标签之后插入 标签,主页就会出现。
import "./App.css";
import Navbar from "./componets/navbar";
import { BrowserRouter as Router, Route, Routes } from "react-router-dom";
import Home from "./pages";
import About from "./pages/about";
function App() {
return (
<Router>
<Navbar />
<Routes>
<Route path="/" exact elements={<Home />} />
<Route path="/about" exact elements={<About />} />
</Routes>
</Router>
);
}
export default App;
我发现了错误。这很简单。它应该是 element
而不是 elements
。所以 s
是错误的。再次感谢。
我有这段代码,但它不显示主页,即位于“/”的页面。但是,如果我在
import "./App.css";
import Navbar from "./componets/navbar";
import { BrowserRouter as Router, Route, Routes } from "react-router-dom";
import Home from "./pages";
import About from "./pages/about";
function App() {
return (
<Router>
<Navbar />
<Routes>
<Route path="/" exact elements={<Home />} />
<Route path="/about" exact elements={<About />} />
</Routes>
</Router>
);
}
export default App;
我发现了错误。这很简单。它应该是 element
而不是 elements
。所以 s
是错误的。再次感谢。