탐색기에서 버튼을 클릭하면 현재 화면의 하나의 TextInput에 포커스가 있습니다. textChange
함수를 트리거하기 위해 TextInput의 인스턴스 블러를 설정해야합니다.React Native : 메소드에서 TextInput 인스턴스 블러를 트리거하는 방법은 무엇입니까?
필자의 경우 TextInput의 커서가 항상 깜박입니다.
refs.username.blur()
이 작동하지 않습니다.
내 코드 : 예상대로
class UploadRecordII extends Component{
static navigationOptions = ({ navigation, screenProps }) => ({
headerRight: (<Button containerStyle={{marginRight: 12,}} onPress={ UploadRecordII.onSubmit}>
<Text style={{color: 'white',fontSize: 18,}}>next</Text>
</Button>),
});
.....
static onSubmit() {
let that = UploadRecordII.instance;
debugger;
that.refs.username.blur();
debugger;
that.props.commitCreateRecordUpdate(that.refs.username._lastNativeText,that.imageList)
that.props.navigation.navigate('Record3');
}
...... in render(){
....
<TextInput ref = 'username' placeholder='' editable = {true} maxLength = {500}
keyboardType='default' multiline={true}
style={styles.input} underlineColorAndroid='rgba(0,0,0,0)'
onBlur={ ()=> this.textChange()}
clearButtonMode='always' placeholderTextColor='#D6D0D8'></TextInput>
...
}
'onChange'를 사용하여'this.description'을 설정하고 버튼을 눌렀을 때'this.description'을 참조하는 것이 잘못된가요? 스크린 샷을 사용하는 대신 코드를 복사하십시오. –
@BenjaminCommet이 질문을 다시 편집합니다. 내 코드가 변경되었습니다. – jiexishede