只读反应原生TextInput

Sha*_*ika 2 react-native

我想在我的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;
Run Code Online (Sandbox Code Playgroud)

eig*_*ive 11

更好的readonly文本输入:

<View pointerEvents="none">
  <TextInput value="I am read only" editable={false} />
</View>
Run Code Online (Sandbox Code Playgroud)

https://facebook.github.io/react-native/docs/view#pointerevents


Sat*_*ram 9

 <TextInput
    value = "Read Only"
    editable = {false}
 />
Run Code Online (Sandbox Code Playgroud)

将editable false设置为只读TextInput.