我想在RN应用程序中使文本输入为只读。我试图设置可编辑的道具,但无法正常工作。我该如何实现?
<DetailInput
inputStyle={styles.inputStyles}
height={120}
width={width - 40}
multiline={true}
numberOfLines={6}
underlineColorAndroid="transparent"
maxLength={500}
editable={!userRegistrationInProgress}
onChangeText={value => this.statementChangedHandler(value)}
/>
const detailInput = props => {
return (
<TextInput
{...props}
style=
{[
props.inputStyle,
{ height: props.height, width: props.width},
!props.valid && props.touched ? props.invalidInput : null
]}
/>
);
}
export default detailInput;
答案 0 :(得分:8)
<TextInput
value = "Read Only"
editable = {false}
/>
将可编辑的false设置为只读TextInput。
答案 1 :(得分:1)
更好的readonly
文本输入:
<View pointerEvents="none">
<TextInput value="I am read only" editable={false} />
</View>
https://facebook.github.io/react-native/docs/view#pointerevents