无法在函数中设置未定义离子的属性

时间:2019-02-06 07:22:16

标签: ionic3

错误:无法将函数中未定义的属性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;
  });

1 个答案:

答案 0 :(得分: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;
}