http://www.cnblogs.com/mlzs/p/3317570.html
如此章所说,点击按钮需要实时更新视图
操作代码如下:
onTasteUp: function (list, record, item, index, btn) {
var visibility = 'visible',
value = +btn.getAttribute("value"),
data = record.data,
taste = data.taste + value,
eateryBar = this.getEateryBar(),
price = value * data.price,
isShop = true;
if (taste == 0) {
visibility = 'hidden';
isShop = false;
}
data.taste = taste;
data.visibility = visibility;
data.isShop = isShop;
item.setData(data);
eateryBar.upDateView(price, value);
}
关键代码为:item.setData(data);
因为所以的展示控件都是基于Container控件的,所以setData方法适用范围很广
经过测试,得出以下结论:
1.不能使用item.setRecord(record);此方法无法更新视图
2.不能使用record.set({taste:taste});查看源码会发现此方法会刷新整个视图,效率及其底下。