React Native 控制一个component的显示隐藏

  1.  
    // 首先在constructor里:
  2.  
    this.state = { visible: false }
  3.  
    // 然后在点击事件设置:
  4.  
    this.setState({ visible: true })
  5.  
    // render函数里利用三木运算:
  6.  
    {this.state.visible ? (
  7.  
    <Alert message="用户名或密码错误" type="warning" showIcon />
  8.  
    ) : null}
posted @ 2020-03-16 11:34  GLORY-HOPE  阅读(1551)  评论(0编辑  收藏  举报