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;
});
解决方案
好的
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;
}
推荐阅读
- php - 在 PHP 中,为什么我不能使用 DomCrawler 抓取此页面以获取 css 选择器文本?
- c# - C#一次创建具有多个值的常量数组
- python - Python RecursionError:超出最大递归深度
- node.js - 最好的一个非常重载的查询 mongodb - Nodejs;聚合、分组、项目和查找
- reactjs - 用于反应的 Material-UI,如何布局 Card 组件以对齐文本
- ios - 为 UITextField 设置 contextType 不起作用
- r - 颜色 aes 断开 geom_line()
- python - 如何知道二维码被扫描了多少次
- python - sklearn DBSCAN 是否假设距离已标准化
- sql - 如何将分隔符从“,”更改为“。” 在 SQL 数据库中用于小数列