zoukankan      html  css  js  c++  java
  • react hooks 获取input输入的值

    import React,{ useState ,useRef} from 'react'
    const VrCornucopiaHome = () => {
      const [projectContent,setProjectContent] = useState()
      const [projectContentNumber,setProjectContentNumber] = useState(0)
     const dateVal = useRef()
     const value = useRef()
      return (
        <div>
          
          <input type="number" ref={dateVal} defaultValue={phoneNumber} placeholder='系统自动带出当前登录人电话' onChange={ (e) => {
              value.current.value = dateVal.current.value   //第一次方式
                    e.target.value  //第二种方式
               }}></input>
          
              <textarea defaultValue={projectContent} placeholder="请输入内容" onChange={ (e) => {
                   let str = e.target.value
                   if(str.length <= 300){
                      setProjectContent(e.target.value)
                      setProjectContentNumber(str.length)
                   }
              }}></textarea>

        </div>
      )
    }
    export default VrCornucopiaHome
  • 相关阅读:
    LINUX开发使用的3个远程工具
    NDK 链接第三方静态库的方法
    GMap.NET 显示GIF图标的定制
    从MySQL获取数据
    web2py远程开发
    升级后,使用dynamic报错
    实用的MVVM:ImageView
    node.js 连接 mysql
    vector常见用法
    XCODE中配置使用boost
  • 原文地址:https://www.cnblogs.com/tlfe/p/14777307.html
Copyright © 2011-2022 走看看