小程序在WXML页面添加的data属性,在点击事件中,获取的属性名皆为小写字母

WXML: 
<view class="smallImg" bindtap="upload" data-uploadAttribute='cover'>
     <image mode='widthFix' src='{{item.cover}}' class="bigImg"></image>
</view>



JS

upload:function(e){
   var that=this;
   console.log(e)     
   var number=1,attr=e.currentTarget.dataset.uploadattribute,data={};
   if(attr=='cover'){
       //上传封面
       data={number:1,name:'cover'};
       that.upImg(data)
   }
}

  

 图片:

 

原文地址:https://www.cnblogs.com/liuqingxia/p/15562279.html