【问题标题】:How To apply css properties in react native by using refs dynamically如何通过动态使用 refs 在 react native 中应用 css 属性
【发布时间】:2015-10-25 04:42:25
【问题描述】:

这是我的实例 我需要获取登录 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>)
}
})`

【问题讨论】:

  • 这是 JavaScript 吗?那些 XML 文字是什么?
  • react native 中没有 div 也没有 getDOMNode
  • 像 setNativeProps 有没有办法通过 ref(getNativeProps) 获取数据我需要获取从 TextInput 输入的值

标签: xcode reactjs ios-simulator react-native refs


【解决方案1】:

你可以这样做:

render: function() {
    if(this.props.show) {
        return (<View ref="login">
              <Text>Abc</Text>
              <Text>123</Text>
            </View>)
    } else {
        return null;
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-08-10
    • 1970-01-01
    • 1970-01-01
    • 2019-12-10
    • 1970-01-01
    • 1970-01-01
    • 2020-01-14
    • 1970-01-01
    相关资源
    最近更新 更多