WXML:

<view id="tapTest" data-hi="WeChat" data-id="99" bindtap="tapName"> Click me! </view>

JS:

Page({
  tapName: function (event) {
    //获取数据详情所有内容;
    console.log(event)
    //获取数据绑定的data- 所有的数据
    console.log(event.currentTarget.dataset.id);
    console.log(event.currentTarget.dataset.hi);
    //获取数据所有的id
    console.log(event.currentTarget.id);
  }
})

 

相关文章:

  • 2022-12-23
  • 2021-12-01
  • 2023-03-20
  • 2021-09-30
  • 2021-06-08
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-08-25
  • 2021-10-11
  • 2022-02-15
相关资源
相似解决方案