How to access custom attributes from event object in React?

前端 未结 15 2065
不思量自难忘°
不思量自难忘° 2020-11-27 09:27

React is able to render custom attributes as described at http://facebook.github.io/react/docs/jsx-gotchas.html:

If you want to use a custom attribut

15条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-27 10:04

    // Method inside the component
    userClick(event){
     let tag = event.currentTarget.dataset.tag;
     console.log(tag); // should return Tagvalue
    }
    // when render element
    Click me
    

提交回复
热议问题