1. 小程序可以通过写 data-index="{{index}}"   来绑定数据(data后面这个可以取任意名字,但获取的时候要写相对应的名字,例:currentTarget.XX) ,记得要bindtap点击执行这个函数才能获取到currentTarget.dataset

例如:

<view  data->点击获取data-id绑定的id值</view>

 

a:function(event){

     console.log(event)    //打印出view中所有属性的值,包括“点击获取data-id绑定的id值”

     console.log(event.currentTarget.dataset.id)    //打印出data-id绑定的id值

     console.log(event.currentTarget.dataset.haha)   //打印出index的值

     console.log(event.currentTarget.id)    //打印出aabb     

}

相关文章:

  • 2022-02-26
  • 2022-12-23
  • 2021-10-05
  • 2021-06-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-30
  • 2022-12-23
  • 2022-01-07
  • 2022-12-23
  • 2022-12-23
  • 2021-10-20
相关资源
相似解决方案