核心代码如下:
async onLoad() {
this.serviceProviders = await this.network().getProviders();
this.$apply();
}
/*放置网络访问函数*/
network() {
let self = this;
return {
async getProviders() {
let user = AV.User.current();
let userLocation = user.get('location');
let serviceProviders = await new AV.Query('ServiceProvider')
.equalTo('status', 0)
.withinKilometers('defCertLocation', userLocation, 1000.0)
.find();
// let newServiceProviders = []
for (let i = 0; i < serviceProviders.length; i++) {
let sp = serviceProviders[i];
sp.set('fcategorys', await sp.relation('categorys').query().find());
let defCertLocation = sp.get('defCertLocation');
let distance = (defCertLocation.kilometersTo(userLocation)).toFixed(2);
sp.set('distance', distance);
// newServiceProviders.push(sp.toJSON())
}
// return newServiceProviders;
return serviceProviders;
}
};
}
报如下错误:
如果修改成以下代码则不会报错:
async onLoad() {
this.serviceProviders = await this.network().getProviders();
this.$apply();
}
/*放置网络访问函数*/
network() {
let self = this;
return {
async getProviders() {
let user = AV.User.current();
let userLocation = user.get('location');
let serviceProviders = await new AV.Query('ServiceProvider')
.equalTo('status', 0)
.withinKilometers('defCertLocation', userLocation, 1000.0)
.find();
let newServiceProviders = []
for (let i = 0; i < serviceProviders.length; i++) {
let sp = serviceProviders[i];
sp.set('fcategorys', await sp.relation('categorys').query().find());
let defCertLocation = sp.get('defCertLocation');
let distance = (defCertLocation.kilometersTo(userLocation)).toFixed(2);
sp.set('distance', distance);
newServiceProviders.push(sp.toJSON())
}
return newServiceProviders;
// return serviceProviders;
}
};
}
使用leancloud版本是最新的3.11.0,请问一下是什么问题?而且好多地方都会报这个错误!