美文网首页
umi权限路由跳转至登录

umi权限路由跳转至登录

作者: 第2世界 | 来源:发表于2020-02-05 19:52 被阅读0次

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

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

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

相关文章

网友评论

      本文标题:umi权限路由跳转至登录

      本文链接:https://www.haomeiwen.com/subject/yehexhtx.html