umi权限路由跳转至登录

2020-02-05  本文已影响0人  第2世界

render是纯函数,不能在其中进行判断,可以使用UNSAFE_componentWillMount,就是之前的componentWillMount

  UNSAFE_componentWillMount(){
    const { isLogin } = this.props;

    if (!isLogin) {
      message.warning('您需要先登陆');
      return (
        <Redirect to="/login" />
      )
    }
  }
上一篇 下一篇

猜你喜欢

热点阅读