在本机反应中输入一些输入值后禁用文本输入
disable text input after entering some input value in react native
这是我正在使用的文本输入,我希望在输入 value.I 后禁用输入字段尝试使用可编辑的道具,但没有帮助。
我是 React Native 的新手,请帮忙举个例子。
<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
道具中使用支票
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 后输入应该被禁用。
这是我正在使用的文本输入,我希望在输入 value.I 后禁用输入字段尝试使用可编辑的道具,但没有帮助。 我是 React Native 的新手,请帮忙举个例子。
<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
道具中使用支票
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 后输入应该被禁用。