小程序中view的自定义属性获取


e.target 拿的是点击的对象的属性

e.currentTarget 则是拿 bintap/catchtap 所在的对象的属性~,点击里面的元素一样能拿到属性值

<view class='a-child' data-tid='{{child.ID}}' bindtap='selectChild'>
  <image class='avatar' src='../../images/localImages/default_user.png'></image>
</view>

selectChild: function(e) {
//获取ID
var tid = e.currentTarget.dataset.tid
console.log('tid: ' + tid)
},


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM