错误:无法设置的未定义的属性X2在函数中使用
x2 : string;
const provider = new OpenStreetMapProvider();
const results = provider.search({query : this.city}).then( function(e){
console.log("function(e)",e[0]);
this.x2=e[0].x;
});
好
x2 : string;
const provider = new OpenStreetMapProvider();
const results = provider.search({query : this.city}));
results.then( (e) => {
console.log("function(e)",e[0]);
this.x2=e[0].x;
}