答案 0 :(得分:3)
您可以将属性设置为editable,并选择TextOnFocus为false
像:
<TextInput editable={false} selectTextOnFocus={false} />
答案 1 :(得分:0)
只需将选择设置为文本末尾: selection = {{start:this.state.text.length,end:this.state.text.length}}
答案 2 :(得分:0)
我想我有两个想法。
您可以在组件selectTextOnFocus
中尝试设置属性 clearTextOnFocus
=“false”TextInput
=“true”:
如果TextInput是焦点,您可以使用onChangeText创建一个删除文本的方法。
我希望我的想法可以帮助你...
答案 3 :(得分:0)
您可以使用选择属性。然后,当选择更改时,将选择道具设置为选择的结束位置。
class App extends React.Component {
constructor(props) {
super(props);
this.state = {
selection: { start: 0, end: 0 },
};
}
onSelectionChange = ({ nativeEvent: { selection, text } }) => {
this.setState({ selection: { start: selection.end, end: selection.end } });
};
render() {
return (
<TextInput
onSelectionChange={this.onSelectionChange}
selection={this.state.selection}
value={this.state.value}
/>
);
}
}