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}

猜你喜欢

转载自www.cnblogs.com/gloryhope/p/12502738.html