problème:
Par exemple, la méthode A () appelle la méthode B (), puis la méthode B renvoie une valeur à A. Après avoir reçu cette méthode, A continuera d'exécuter le code suivant. Comment? ?
résoudre:
methods: {
async A() {
const result = await B();
// dosomethings . . .
},
B() {
// dosomethings . . .
return Promise.resolve(data);
}
}
Mon code
loadMap () {
..............
// map.addControl(newControl);
return Promise.resolve(map);
},
async orientClick(){
//获得上面的方法的返回值
var map = await this.loadMap();
// map = new T.Map("mapDiv", {datasourcesControl: true});
map.panTo(new T.LngLat(110.074846, 39.201972), 15);
}