Я использую в своем проекте библиотеку response-router-dom "^ 4.3.1", и у меня есть страница входа и страницы администратора. После входа в систему я хочу перенаправить домашнюю страницу на страницы администратора (history.push ('/ home');), но браузер отображает пустую страницу. Как я могу решить эту проблему?
мой основной роутер.
<Router history = {history}>
<Switch>
<Route path = "/register" name = "Register Page" component = {Register}/>
<Route path = "/404" name = "Page 404" component = {Page404}/>
<Route path = "/500" name = "Page 500" component = {Page500}/>
<Route path = "/home" name = "Home" component = {Full}/>
<Route path = "/" name = "Login" component = {Login}/>
</Switch>
</Router>
Полное содержание компонента:
<div className = "app">
<Header/>
<div className = "app-body">
<Sidebar {...this.props}/>
<main className = "main">
<Breadcrumb/>
<Container fluid>
<Switch>
<Route path = "/dashboard" name = "Dashboard" component = {Dashboard}/>
<Route path = "/applications" name = "Applications" component = {Applications}/>
<Route path = "/roles" name = "Roles" component = {Roles}/>
<Route path = "/poc" name = "poc" component = {Poc}/>
<Redirect from = "/home" to = "/dashboard"/>
</Switch>
</Container>
</main>
<Aside/>
</div>
<Footer/>
</div>
Вы можете помочь мне?
добавьте код своей домашней страницы
я добавил комментарий для компонента домашней страницы





я пробую this.props.history.push ('/ home'); часть кода, но работает некорректно.
Вы можете увидеть мои коды компонентов ниже. мой полный код компонента:
class Full extends Component {
render() {
return (
<div className = "app">
<Header/>
<div className = "app-body">
<Sidebar {...this.props}/>
<main className = "main">
<Breadcrumb/>
<Container fluid>
<Switch>
<Route path = "/dashboard" name = "Dashboard" component = {Dashboard}/>
<Route path = "/applications" name = "Applications" component = {Applications}/>
<Route path = "/roles" name = "Roles" component = {Roles}/>
<Route path = "/poc" name = "poc" component = {Poc}/>
<Redirect from = "/home" to = "/dashboard"/>
</Switch>
</Container>
</main>
<Aside/>
</div>
<Footer/>
</div>
);
}
}
Dashboard component code :
class Dashboard extends Component {
constructor(props) {
super(props);
}
render() {
return (
<div className = "animated fadeIn">
<div>test</div>
</div>
)
}
}
export default Dashboard;
Исторический код:
import {createBrowserHistory} from 'history';
export const history = createBrowserHistory();
вы пробовали this.props.history.push ('/ home')?