如果textinput中的文本较长,我想重设光标位置,但是我不确定如何实现。这是我的代码。
constructor(){
this.state = {
selection:{start:0,end:0}
}
}
.....
resetCursor = () => {
const selection = {start:1,end:1};
this.subject.setNativeProps({selection});
this.setState({selection});
}
.....
<Input
ref = {ref => this.subject = ref}
placeholder="Subject"
selection={this.state.selection}
inputContainerStyle={Styles.inputContainer}
inputStyle={Styles.inputBlackStyle}
placeholderTextColor={"#d3d3d3"}
onChangeText={subject => {
this.setState({ subject });}}
onBlur = {this.resetCursor}
/>
我在这里做错了!!