在vue项目中,我在methods方法里掉用了高德的api转百度的经纬度AMap.convertFrom(this.list[i].lnglats, 'baidu', function(meg, res) { let _lnglats = [res.locations[0].lng, res.locations[0].lat] // 替换原来的经纬度 this.transformLnglats.push(_lnglats) console.log(this.transformLnglats) console.log(this.transformLnglats[0])}.bind(this))如果在里面答应的话可以访问到数组的长度和里面的内容,但是在方法的外面再次打印的时候就访问不到了AMap.convertFrom(this.list[i].lnglats, 'baidu', function(meg, res) { let _lnglats = [res.locations[0].lng, res.locations[0].lat] // 替换原来的经纬度 this.transformLnglats.push(_lnglats)}.bind(this))console.log(this.transformLnglats)console.log(this.transformLnglats[0])console.log(this.transformLnglats[0]) 打印出来的结束是这样的可是却找不到里面的长度和数组,这是为哈呢?唯一不一样的地方就是我标红的这块,这两个之间有什么区别呢?
添加回答
举报
0/150
提交
取消
