我的用例是这样的:
我有一个输入元素,我希望与该元素关联一个自定义属性,以便我可以将字符串数据添加到该特定元素并检索它。
我应该如何实现这一目标?
最佳答案
你可以给我们这样的东西:
<input data-customValue="somevalue" .../>
然后用类似的东西检索:
let customValue = element.dataset.customValue;
关于reactjs - react : How to add custom properties to html elements,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54920150/