<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; }
