<button hover="true" class="Itembtn"
wx:for="{{zheng}}"
wx:for-index="index"
data-index="{{index}}"
wx:for-item="item"
bindtap="zhengzhuang"
hover-class="btnhover">{{item.dosageUnit}}</button>
//其中wx:for="{{zheng}}",zheng是从后台请求的数组,item.dosageUnit是数组中每一个元素,字段是dosageUnit
zhengzhuang: function (e) {
var that = this;
//获取下标
var idx = e.target.dataset.index;
console.log(idx)
}
网友评论