<button @click="getNearby" class="nearby">{{ destinationAddress }}</button>
setDestinationAddress (addressComponents) {
this.destinationAddress = addressComponents.city + addressComponents.district + addressComponents.street + addressComponents.streetNumber
},
getLocation (point) {
let that = this
var geoc = new window.BMap.Geocoder()
geoc.getLocation(point, function (rs) {
consoles(rs)
that.setPoint(that.marker, rs.point)
that.setPoint(that.destination, rs.point)
that.setDestinationAddress(rs.addressComponents)
})
},
locationSuccess ({point, addressComponent, marker}) {
consoles(addressComponent)
this.zoom = 16
this.setPoint(this.current, point)
this.setPoint(this.marker, point)
this.setPoint(this.destination, point)
this.setDestinationAddress(addressComponent)
}
locationSuccess is a successful callback of Baidu map positioning. The variable destinationAddress is modified by the callback of getLocation, and then an error is reported if it is modified by locationSuccess.
Uncaught TypeError: Cannot read property "Ha" of null
at Ka.eval (eval at zZ (getscript?v=2.0&ak=aaaaa&services=&t=20180629105709:1), <anonymous>:1:556)
at Ka.x.lang.Ca.dispatchEvent (getscript?v=2.0&ak=aaaaa&services=&t=20180629105709:1)
at Ka.Dd (getscript?v=2.0&ak=aaaaa&services=&t=20180629105709:1)
at Geolocation.eval (eval at zZ (getscript?v=2.0&ak=aaaaa&services=&t=20180629105709:1), <anonymous>:1:1202)
at d (eval at zZ (getscript?v=2.0&ak=aaaaa&services=&t=20180629105709:1), <anonymous>:1:1803)
at eval (eval at zZ (getscript?v=2.0&ak=aaaaa&services=&t=20180629105709:1), <anonymous>:1:2145)
at window.(/anonymous function) (eval at zZ (https://api.map.baidu.com/getscript?v=2.0&ak=aaaaa&services=&t=20180629105709:1:54250), <anonymous>:1:9263)
at ip?qt=loc&coor=bd09ll&ak=aaaaa&timeout=10000&callback=_cbk16835:1
(anonymous) @ VM151757:1
x.lang.Ca.dispatchEvent @ getscript?v=2.0&ak=aaaaa&services=&t=20180629105709:1
Dd @ getscript?v=2.0&ak=aaaaa&services=&t=20180629105709:1
(anonymous) @ VM151757:1
d @ VM151752:1
(anonymous) @ VM151752:1
window.(anonymous function) @ VM151752:1
(anonymous) @ ip?qt=loc&coor=bd09ll&ak=aaaaa&timeout=10000&callback=_cbk16835:1
locationSuccess is a successful callback of Baidu map positioning. The variable destinationAddress is modified by the callback of getLocation, and then an error is reported if it is modified by locationSuccess. I don"t know why