码迷,mamicode.com
首页 > 其他好文 > 详细

react 中的blur事件

时间:2018-12-24 20:25:12      阅读:944      评论:0      收藏:0      [点我收藏+]

标签:htm   reac   tps   input   问题   develop   focus   fun   NPU   

我们知道,想要手动触发blur事件时候,可以使用:https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/blur

Element.blur()

然而在react中,当你想手动触发一个input的blur事件时,你会得到一个错误:blur is not a function

在react中,当我们要操纵dom时候,我们一般会使用ref,比如focus事件:

this.ref.current.focus() // 这个会运行的很好
this.ref.current.blur() // 这个会报错

 

解决办法:避开了直接触发blur事件。。。(好low啊感觉,直接逃避问题???♀?)

react 中的blur事件

标签:htm   reac   tps   input   问题   develop   focus   fun   NPU   

原文地址:https://www.cnblogs.com/yadiblogs/p/10170704.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!