这是我正在使用的文本输入,我希望输入输入后,我希望输入值。我尝试使用可编辑的道具,但没有帮助。我是新手反应的新手,请帮助一个例子。
<View style={editProfileStyle.textinputView}>
<TextInput
style={editProfileStyle.textInput}
placeholder="Enter your Specialization"
value={this.state.subQualification}
onChangeText={subQualification => this.setState({ subQualification: subQualification })}
/>
</View>
根据问题,因为该字段应在具有一定值时被禁用:
<View style={editProfileStyle.textinputView}>
<TextInput
editable={this.state.subQualification.length === 0}
style={editProfileStyle.textInput}
placeholder="Enter your Specialization"
value={this.state.subQualification}
onChangeText={subQualification => this.setState({ subQualification: subQualification })}
/>
</View>
使用
的editable
prop中使用检查 editable={this.state.subQualification.length === 0}
将在字段中没有任何目前的情况下使字段可编辑
尝试添加状态并像这样修改您的textInput道具:
state ={
textDisable: true
}
render() {
return (
<View style={editProfileStyle.textinputView}>
<TextInput
style={editProfileStyle.textInput}
placeholder="Enter your Specialization"
value={this.state.subQualification}
onChangeText={subQualification => this.setState({ subQualification: subQualification })}
editable={this.state.textDisable}
onEndEditing={() => this.setState({textDisable: false})}
/>
</View>
);
}
}
onsubmit后应禁用输入。