我正在构建一个网站,我不想在 2 个页面中显示导航栏。其中一个是 404 页面,我将在其中提供一个重定向按钮。另一个是网站的登陆页面,我将在其中提供一个按钮,该按钮将重定向到网站的主页。这是我的 app.js 代码,我在其中定义了路线。
import React from "react";
import "./App.css";
import { BrowserRouter as Router, Switch, Route } from "react-router-dom";
import Navbar from "./Components/Navbar";
import Home from "./Components/Pages/Home";
import PlanYourTrip from "./Components/Pages/PlanYourTrip";
import AboutUs from "./Components/Pages/AboutUs";
import SafetyMeasures from "./Components/Pages/SafetyMeasures";
import Travel from "./Components/Pages/Travel";
import Error from "./Components/Pages/404";
function App() {
return (
<>
<Router>
<Navbar />
<Switch>
<Route path="/" exact component={Travel} />
<Route path="/home" exact component={Home} />
<Route path="/plan-your-trip" exact component={PlanYourTrip} />
<Route path="/about-us" exact component={AboutUs} />
<Route path="/safety-measures" exact component={SafetyMeasures} />
<Route component={Error} />
</Switch>
</Router>
</>
);
}
export default App;
我想从<Route path="/" exact component={Travel} /> 和 中 删除导航栏<Route component={Error} />。请帮忙。
Qyouu
慕田峪9158850
holdtom
aluckdog
相关分类