我试图捕获单击事件发生的标记,但是,我得到的不是实际标记。您的帮助将不胜感激
我试图抓住的标签 button
<button type="button" onClick={(e) => handleAction(row, e)}>
<img src={options} alt="more options" />
</button>
通过道具
handleAction={this.handleAction}
handleAction方法
handleAction(row, e) {
console.log(e.target, row);
}
输出
<img src="/bf8a277f232f78afa8e14c7f6147fc88.png" alt="more options">, myRow
尝试使用currentTarget而不是target:
console.log(e.currentTarget, row);
e.target将返回img标签,但e.currenTarget将返回button标签
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句