不能设置在函数未定义离子的特性

问题描述 投票:0回答:1

错误:无法设置的未定义的属性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;
  });
ionic3
1个回答
0
投票

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;
}
© www.soinside.com 2019 - 2024. All rights reserved.