In the vue project, I push an array in methods, but I can't find its length and the value that push enters.

in the vue project, I lost the latitude and longitude of Gaud"s api to Baidu in the methods method

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))

if you agree in it, you can access the length and contents of the array.

clipboard.png


clipboard.png

but I can"t find the length and array inside. Why? The only difference of
is the one I marked red. What"s the difference between the two?

Mar.20,2021

I think there is something wrong with your this. The this may still be vue when it is introduced, but the later one may not be the same. It is recommended to try var _ this = this; first

.

in addition, your assignment is performed in a callback function, and you may not have completed the assignment outside.

Menu