React-Native一次性绑定

我想从状态中的对象分配一个值,而不将其绑定到状态。

<TextInput value={this.state.bigObject.sub.name}/>
<TextInput value={this.state.bigObject.sub.name.toString()}/> // also tried this

编辑文本框时,该值将恢复为状态中的值。我不想更新状态onChange,而只想更新状态onSubmitEditing。我该如何实现?

layjung0 回答:React-Native一次性绑定

使用setNativeProps直接操作TextInput。希望有帮助

 <TextInput
          ref={component => this._textInput = component}
          style={{height: 50,width: 200,marginHorizontal: 20,borderWidth: 1,borderColor: '#ccc'}}
        />
this._textInput.setNativeProps({text: ''});
本文链接:https://www.f2er.com/3166173.html

大家都在问