首页 > 其他分享 >React Native TextInput输入组件,聚焦全选功能

React Native TextInput输入组件,聚焦全选功能

时间:2023-03-09 11:34:00浏览次数:42  
标签:current end setSelection inputRef React 全选 onFocus null TextInput

在onFocus
在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); }}

标签:current,end,setSelection,inputRef,React,全选,onFocus,null,TextInput
From: https://www.cnblogs.com/zzgyq123/p/17197718.html

相关文章

  • 前端路由(vue2 + vue3 + react)
    前端路由的设置:Vue2路由(vue-router3)安装插件npmivue-router@3router/index.js文件设置importVuefrom"vue";importVueRouterfrom"vue-router";Vue.use(VueRo......
  • react业务开发笔记1
    自定义table空数据import{ConfigProvider,Table,}from'antd'//定义空数据展示constrenderEmpty=()=>(<EmptyimageStyle={{he......
  • 完整手写react第五天
    如何触发更新常见的触发更新的方式:ReactDOM.createRoot().render(或老版的ReactDOM.render)this.setStateuseState的dispatch方法接下来的工作包括:实现mount时调用......
  • 完整手写react第四天
    实现Reconciler架构ReactElement如果作为核心模块操作的数据结构,存在的问题:无法表达节点之间的关系字段有限,不好拓展(比如:无法表达状态)所以,需要一种新的数据结构,他的......
  • React课堂笔记3-生命周期
    一、组件component(续)1.1、组件的state1.1.1、componentWillUnmountcomponentWillUnmount() 会在组件卸载及销毁之前直接调用。在此方法中执行必要的清理操作,例如,清除t......
  • React 中使用React-Router
    React-Router帮助我们实现单页应用的路由跳转功能1.简单路由src/pags/home.jsconstHome=()=>{return(<div>Home</div>);};src/Routes.jsimpo......
  • react-router-dom V6路由参数
    一、标签组件  1.search方式    <Linkto={'/main/dataForm?id=123&name=aa'}>导航</Link>    <Linkto={{pathname:'/main/dataForm',search:`?id=123&na......
  • React - 改变不受控制的输入
    我有一个简单的React组件,我认为它具有一个受控输入的形式:importReactfrom'react';exportdefaultclassMyFormextendsReact.Component{constructor(......
  • 【前端】一个更底层库-React基础知识
    (目录)这一篇学习React知识点。分别从属性状态和相关API了解一下。属性状态属性状态要知道这几个PROPS,PROPVALIDATION,STATE。PROPS通过this.props可以获取传递给该......
  • JavaScript 全选练习
    <!DOCTYPEhtmlPUBLIC"-//W3C//DTDHTML4.01Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"><html><head><metahttp-equiv="Content-Type"content="t......