如何让js等待回调函数执行

时间:2018-06-02 20:16:55

标签: javascript

谷歌地图中的路线映射功能:

this.directionsService.route({
  origin: "Moscow",
  destination: $('#address_to').val(),
  waypoints: waypts,
  optimizeWaypoints: true,
  travelMode: 'DRIVING'
}, (response, status) => {
  if (status === 'OK') {
    // marker.setMap(null);
    this.directionsDisplay.setDirections(response);
    return true;
    } else {
      return false;
    }
});

如何强制等待执行回调函数?

0 个答案:

没有答案