You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
// 引入两个组件
import Layout from "./Layout"; import Board from "./Board"; import Article from "./Article"; import NotFound from "./NotFound";
import { BrowserRouter, Routes, Route} from "react-router-dom"
// 进行路由配置
function App() { return (
<BrowserRouter>
<Routes>
<Route path="/" element={<Layout/>}> {/* 定义二级路由嵌套 */} <Route path="board" element={<Board/>}></Route> <Route path="Article" element={<Article/>}></Route> </Route>
{/* 当所有的路径都没有匹配时,做兜底匹配,显示未找到 */} <Route path="*" element={<NotFound/>}></Route> </Routes> </BrowserRouter> ); }
export default App;
|