0
當我有下面的代碼,這樣的進口:陣營路由器4 - 隱藏導航的「/」路線
import {
BrowserRouter as Router,
Switch,
Route,
Link
} from 'react-router-dom'
import { Comics } from './Comics';
import { Books } from './Books';
import { Projects } from './Projects';
import { Navigation } from './Navigation';
function App() {
return (
<Router>
<div className="App">
<Navigation loggedInUser={loggedInUser} />
<Route path="/" exact component={Home} />
<Switch>
<Route path= "/comics" component={Comics} />
<Route path="/books" component={Books}/>
<Route path="/projects" component={Projects} />
</Switch>
</div>
</Router>
)
}
如何隱藏導航當我在「/」路線?我可以在每條路線上渲染導航,但我不認爲這是一個好主意的表現?
斜線後請附上您的進口供代碼片段參考 – hasnat