<li className="proviceLi" data-name="山东" onClick={(e)=>this.selectProvice(e)}>山东</li>
selectProvice=(e)=>{
console.log(e.currentTarget.getAttribute("data-name"))
}
React获取当前点击元素的属性值(标签上绑定值)
最新推荐文章于 2023-10-14 13:58:01 发布
<li className="proviceLi" data-name="山东" onClick={(e)=>this.selectProvice(e)}>山东</li>
selectProvice=(e)=>{
console.log(e.currentTarget.getAttribute("data-name"))
}