我有一个导航栏组件,我正在尝试将其组合在一起,但我的 App.js 出现问题,我在其中调用了所有组件。我必须渲染导航栏两次才能使其工作,但它出现了两次,其中只有第二个导航栏起作用。在渲染中取出 2 行代码中的任何一行都会导致错误,其中只显示导航栏的文本(但只显示一次,而不是两次),并且不可点击。
这是 render() 导航栏渲染两次:
render() {
return (
<div>
<Login />
<Search />
<BrowserRouter>
<div className='container'>
<Navbar />
<Route component={Navbar}/>
<Route exact path="/" component={Home}/>
<Route path="/bios" component={Bios}/>
<Route path="/message" component={Message}/>
</div>
</BrowserRouter>
</div>
);
}
