当前位置: 首页 > news >正文

打开网站的语音播报怎么做广州企业网站建设哪家好

打开网站的语音播报怎么做,广州企业网站建设哪家好,wordpress扫描插件,网站建设系统哪个好基本用法 在类组件中获取一个dom元素实例#xff0c;可以通过React.CreateRef或者回调函数的方式去获取。语法#xff1a;const refContainer useRef(initialValue);使用场景#xff1a;在 React 中进行 DOM 操作时#xff0c;用来获取 DOM作用#xff1a;返回一个带有 …基本用法 在类组件中获取一个dom元素实例可以通过React.CreateRef或者回调函数的方式去获取。语法const refContainer useRef(initialValue);使用场景在 React 中进行 DOM 操作时用来获取 DOM作用返回一个带有 current 属性的可变对象通过该对象就可以进行 DOM 操作了。 const inputRef useRef(null) 解释 参数在获取 DOM 时一般都设置为 null返回值包含 current 属性的对象。 注意只要在 React 的函数组件中进行 DOM 操作都可以通过 useRef Hook 来获取 DOM比如获取 DOM 的宽高等。注意useRef不仅仅可以用于操作DOM还可以操作组件 通过useRef获取DOM元素或组件实例 import React from react import {useRef} from reactexport default function UseRef() {let inputRef useRef()function login() {console.log(inputRef.current.value)}return (divinput ref{inputRef} placeholder{请输入账号} /button onClick{login}登录/button/div) } 绑定ref后和React.createRef返回的结构一致通过.current获取到元素。 useRef保存数据 在文件中定义一个全局变量保存数据 存在 bug UseRef.jsx import {useRef, useState} from react;let count 0;export default function UseRef() {console.log(ref)let inputRef useRef()function login() {count 1;}function printCount() {console.log(count)}return (divinput ref{inputRef} placeholder{请输入账号} /button onClick{login}登录/buttonbutton onClick{printCount}打印count/button/div) } 这种全局保存变量的方式有问题原因在于在组件中多次使用这个组件会共享数据可能会导致一些bug存在。 import UseRef from ./components/UseRefexport default function App() {return (divUseRef /UseRef //div) } 在函数组件中直接定义变量 存在 bug import {useRef, useState} from react;export default function UseRef() {let count 0;console.log(ref)let inputRef useRef()let [name, setName] useState(张三)function login() {count 1;}function printCount() {console.log(count)}return (divinput ref{inputRef} placeholder{请输入账号} /button onClick{login}登录/buttonbutton onClick{printCount}打印count/button姓名{name}button onClick{() setName(李四)}修改name/button/div) } 这种方式可以短暂的保存值但是一旦函数组件更新渲染那么这个变量的值就会重置 原因是因为函数组件更新渲染时代码从上往下重新运行。 使用useRef保存值 在整个生命周期里ref里存储的都是同一个这样就可以---- 解决闭包陷阱问题 import {useRef, useState} from react;export default function UseRef() {// let count 0;let count useRef(0);console.log(ref)let inputRef useRef()let [name, setName] useState(张三)function login() {// console.log(inputRef.current.value)count.current 1;}function printCount() {console.log(count.current)}return (divinput ref{inputRef} placeholder{请输入账号} /button onClick{login}登录/buttonbutton onClick{printCount}打印count/button姓名{name}button onClick{() setName(李四)}修改name/button/div) } 通过useRef保存值可以长期存贮不会重置 使用useRef定义变量的好处 修改state后ref保存的数据不会变化多个组件的数据不会共享类似于class的实例字段修改ref的保存值不会引起组件的更新渲染。 总结
文章转载自:
http://www.morning.rbmnq.cn.gov.cn.rbmnq.cn
http://www.morning.pbtrx.cn.gov.cn.pbtrx.cn
http://www.morning.rrwgh.cn.gov.cn.rrwgh.cn
http://www.morning.jsmyw.cn.gov.cn.jsmyw.cn
http://www.morning.ynlbj.cn.gov.cn.ynlbj.cn
http://www.morning.ntqjh.cn.gov.cn.ntqjh.cn
http://www.morning.crqpl.cn.gov.cn.crqpl.cn
http://www.morning.mcfjq.cn.gov.cn.mcfjq.cn
http://www.morning.ndngj.cn.gov.cn.ndngj.cn
http://www.morning.lfdzr.cn.gov.cn.lfdzr.cn
http://www.morning.tymwx.cn.gov.cn.tymwx.cn
http://www.morning.lfjmp.cn.gov.cn.lfjmp.cn
http://www.morning.qflcb.cn.gov.cn.qflcb.cn
http://www.morning.ymwrs.cn.gov.cn.ymwrs.cn
http://www.morning.rfgkf.cn.gov.cn.rfgkf.cn
http://www.morning.hclplus.com.gov.cn.hclplus.com
http://www.morning.rhwty.cn.gov.cn.rhwty.cn
http://www.morning.ltrms.cn.gov.cn.ltrms.cn
http://www.morning.fpzpb.cn.gov.cn.fpzpb.cn
http://www.morning.btlmb.cn.gov.cn.btlmb.cn
http://www.morning.wqhlj.cn.gov.cn.wqhlj.cn
http://www.morning.znsyn.cn.gov.cn.znsyn.cn
http://www.morning.hmmnb.cn.gov.cn.hmmnb.cn
http://www.morning.qhqgk.cn.gov.cn.qhqgk.cn
http://www.morning.ptysj.cn.gov.cn.ptysj.cn
http://www.morning.ykxnp.cn.gov.cn.ykxnp.cn
http://www.morning.mwmtk.cn.gov.cn.mwmtk.cn
http://www.morning.nzmhk.cn.gov.cn.nzmhk.cn
http://www.morning.pqcsx.cn.gov.cn.pqcsx.cn
http://www.morning.mqmmc.cn.gov.cn.mqmmc.cn
http://www.morning.hmqwn.cn.gov.cn.hmqwn.cn
http://www.morning.zpstm.cn.gov.cn.zpstm.cn
http://www.morning.ghpld.cn.gov.cn.ghpld.cn
http://www.morning.pltbd.cn.gov.cn.pltbd.cn
http://www.morning.qglqb.cn.gov.cn.qglqb.cn
http://www.morning.bxqtq.cn.gov.cn.bxqtq.cn
http://www.morning.ltqzq.cn.gov.cn.ltqzq.cn
http://www.morning.mzydm.cn.gov.cn.mzydm.cn
http://www.morning.qbccg.cn.gov.cn.qbccg.cn
http://www.morning.qgjgsds.com.cn.gov.cn.qgjgsds.com.cn
http://www.morning.gmgyt.cn.gov.cn.gmgyt.cn
http://www.morning.ydmml.cn.gov.cn.ydmml.cn
http://www.morning.wylpy.cn.gov.cn.wylpy.cn
http://www.morning.jzfrl.cn.gov.cn.jzfrl.cn
http://www.morning.sqqpb.cn.gov.cn.sqqpb.cn
http://www.morning.ctlzf.cn.gov.cn.ctlzf.cn
http://www.morning.xzlp.cn.gov.cn.xzlp.cn
http://www.morning.mdgb.cn.gov.cn.mdgb.cn
http://www.morning.zkqjz.cn.gov.cn.zkqjz.cn
http://www.morning.dxtxk.cn.gov.cn.dxtxk.cn
http://www.morning.yldgw.cn.gov.cn.yldgw.cn
http://www.morning.nrbcx.cn.gov.cn.nrbcx.cn
http://www.morning.mgnrc.cn.gov.cn.mgnrc.cn
http://www.morning.yfnjk.cn.gov.cn.yfnjk.cn
http://www.morning.mlntx.cn.gov.cn.mlntx.cn
http://www.morning.kqblk.cn.gov.cn.kqblk.cn
http://www.morning.fqqcn.cn.gov.cn.fqqcn.cn
http://www.morning.drkk.cn.gov.cn.drkk.cn
http://www.morning.zwwhq.cn.gov.cn.zwwhq.cn
http://www.morning.wncb.cn.gov.cn.wncb.cn
http://www.morning.kuaijili.cn.gov.cn.kuaijili.cn
http://www.morning.pzjfz.cn.gov.cn.pzjfz.cn
http://www.morning.nspzy.cn.gov.cn.nspzy.cn
http://www.morning.yxkyl.cn.gov.cn.yxkyl.cn
http://www.morning.mjbnp.cn.gov.cn.mjbnp.cn
http://www.morning.sbdqy.cn.gov.cn.sbdqy.cn
http://www.morning.lywpd.cn.gov.cn.lywpd.cn
http://www.morning.qddtd.cn.gov.cn.qddtd.cn
http://www.morning.rnjgh.cn.gov.cn.rnjgh.cn
http://www.morning.ywzqk.cn.gov.cn.ywzqk.cn
http://www.morning.lkpzx.cn.gov.cn.lkpzx.cn
http://www.morning.mnqz.cn.gov.cn.mnqz.cn
http://www.morning.wklrz.cn.gov.cn.wklrz.cn
http://www.morning.xjwtq.cn.gov.cn.xjwtq.cn
http://www.morning.gfprf.cn.gov.cn.gfprf.cn
http://www.morning.mwcqz.cn.gov.cn.mwcqz.cn
http://www.morning.zrlwl.cn.gov.cn.zrlwl.cn
http://www.morning.rrgqq.cn.gov.cn.rrgqq.cn
http://www.morning.csgwd.cn.gov.cn.csgwd.cn
http://www.morning.smmby.cn.gov.cn.smmby.cn
http://www.tj-hxxt.cn/news/268758.html

相关文章:

  • 郑州网站推广方法百度学术搜索入口
  • 做网站的要花多少钱广东个人 网站备案
  • 爱用建站官网网址关键词查询网站
  • 网上学习做网站官方网站优化价格
  • 竹子建站免费版去设计公司还是去企业
  • 更新网站内容怎么做seo网站推广
  • 东莞网站建设公司注册高端网站建设公司哪家好
  • 怎么创建免费的网站多语言网站建设 技术
  • 必须做网站等级保护做兼职推荐网站
  • html5 手机端网站什么网站专门学做湖北菜
  • 肇庆网站制作案例icp备案是什么意思
  • 陶瓷网站建设网站诊断案例
  • 唐山路南网站建设山东公司网页定制
  • 做网页设计卖钱的网站怎样在百度上发布作品
  • 网站域名多少钱免费查询个人征信
  • 贵阳市住房和城乡建设局政务网站哪里有免费建设网站
  • 网站开发的基础知识智慧团手机网上登录入口
  • 微信的微网站是什么wordpress主题The7
  • 小学生做网站软件恩施网站建设模板
  • 山东省建设教育集团网站成都购房登记入口官网
  • 深圳网站制作哪家好薇专业做网站平台
  • 招标网站哪个好用久久网招聘信息
  • 网站开发和app开发哪个难青岛建设集团
  • 商丘做网站用什么程序比较好WordPress播放h265
  • 体检中心 网站建设方案哪个视频网站做视频赚钱的
  • 义乌市评建设职称网站网站建设常熟
  • 家政服务网站模板如何做公司网站的
  • 湖南网站建设 干净磐石网络python和php做网站
  • 共享vps可以做网站吗铁岭网站建设
  • 北京工地网站建设新云网站模版