<appLayout>
      <Switch>
          <Route path='/' exact render={()=> (
               <Redirect to={this.getDefaultRoute()}/>
           )}/>
        </Switch>
</appLayout>

根据登录与否进入自定义路由

只能判断根路由,子路由不受影响需做另外设置

redirectDefault() {
  const defaultState = <Route to={this.state.defaultState}/>
  const loginState = <Route to="/login"/>
  return this.state.hasLogin ? defaultState : loginState;
}

 

相关文章:

  • 2021-06-08
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-17
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-02-16
  • 2022-12-23
  • 2022-12-23
  • 2021-06-20
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案