<view data-action="father" bindtap="GetAction">
    <image src="https://ss0.baidu.com/6ONWsjip0QIZ8tyhnq/it/u=1302131682,4226401052&fm=58&bpow=492&bpoh=408" mode="widthFix">
    </image>
    <text>文字</text>
</view>


使用第一种的方法e.target.dataset.action   会获取当前点击的元素的action,则获取图片上的action,图片上没有action便取的是undefined;

使用第二种的方法e.currentTarget.dataset.action  会获取有事件的那个元素,即view,所以获得“father”


相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-08
  • 2021-06-16
  • 2022-02-10
  • 2021-11-26
  • 2021-07-13
猜你喜欢
  • 2022-12-23
  • 2021-12-26
  • 2022-02-14
  • 2022-12-23
  • 2021-05-10
  • 2021-11-02
  • 2021-07-31
相关资源
相似解决方案