在按钮上添加data-attr属性值
<view a:for="{{array}}" class="lv">
<text class="lvtxt w4">{{item}}</text>
<button class="btn-do w2" onTap="doUpdate" data-attr='{{item}}'>更新</button>
<button class="btn-do w2" onTap="doDelete" data-attr='{{item}}'>删除</button>
</view>
在.js文件中,添加按钮事件 doUpdate,通过event.target.dataset.attr 获取参数值
doUpdate: function(event) {
var that = this;
var _pmodel = event.target.dataset.attr;
that.setData({
howdo: 'updatepackage',
pmodel: _pmodel,
pmodel_u: _pmodel
});
},