在onFocus
![](https://img2023.cnblogs.com/blog/2936100/202303/2936100-20230309111804692-334370636.png)
在onFocus下有参数传回
在target下有setSelection方法,打印可以传入初始和结尾值
setSelection(start, end) {
if (inputRef.current != null) {
viewCommands.setTextAndSelection(inputRef.current, mostRecentEventCount, null, start, end);
}
}
最终方法
onFocus={(e)=>{
e.target.setSelection(0,currentValue.length);
}}