<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是從后臺請求的數(shù)組晒骇,item.dosageUnit是數(shù)組中每一個元素,字段是dosageUnit
zhengzhuang: function (e) {
var that = this;
//獲取下標(biāo)
var idx = e.target.dataset.index;
console.log(idx)
}