0

这是我的实例,我需要获取登录 div 并使用 refs 隐藏它如何实现?

var Text=React.createClass({
componentDidMount:function(){
  console.log(this.refs.login.getDOMNode());

}, 

render:function(){
return (<View ref="login">
          <Text>Abc</Text>
          <Text>123</Text>
        </View>)
}
})`
4

1 回答 1

0

你可以这样做:

render: function() {
    if(this.props.show) {
        return (<View ref="login">
              <Text>Abc</Text>
              <Text>123</Text>
            </View>)
    } else {
        return null;
    }
}
于 2015-08-03T12:46:18.603 回答