在开发环境执行没有问题,发布到正式环境就出现死循环,导致死循环的原因是获取item后,有setData({item}),导致一直死循环了
observers: {
'item': function (item) {
const $this = this;
if (item == null) {
return;
}
wx.getLocation({
type: 'wgs84',
success(res) {
const latitude = res.latitude
const longitude = res.longitude
$this.setData({
latitude,
longitude
});
if (item) {
item.distance = $this.distance(latitude, longitude, item.latitude, item.longitude);
$this.setData({
item
});
}
}
})
}
},