小程序-在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)
   }
}

  

 图片:

 

posted @ 2021-11-16 17:15  MiniDuck  阅读(83)  评论(0编辑  收藏  举报