reactjs – React的mouseEvent没有offsetX / offsetY
发布时间:2020-12-15 20:52:55 所属栏目:百科 来源:网络整理
导读:我尝试获取点击相对于元素的位置,但事件没有offsetX. onClick(e) { console.log(e.offsetX) // returns undefined console.log(e.target.offsetX) // returns undefined}render() { return img src='http://placehold.it/1000x500' onClick={this.onClick} /
我尝试获取点击相对于元素的位置,但事件没有offsetX.
onClick(e) { console.log(e.offsetX) // returns undefined console.log(e.target.offsetX) // returns undefined } render() { return <img src='http://placehold.it/1000x500' onClick={this.onClick} /> } 如何获得点击元素的位置?
哦,好吧,我明白了. 我从e.nativeEvent.offsetX得到它.是对的吗?
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |