全局变量不会改变

时间:2018-06-05 16:09:35

标签: javascript global-variables

我在javascript中遇到全局变量的问题。 为什么纬度和经度不会改变?

var latitude;
var longitude;
  function initMap() {
    var reportDb = firebase.database().ref("Report");
    reportDb.once("value").then(function(snapshot) {
      snapshot.forEach(function(childSnapshot) {
        longitude = childSnapshot.child("longitudine").val();
        latitude = childSnapshot.child("latitudine").val();
      });
    })window.alert(longitude);}

与纬度相同的问题

0 个答案:

没有答案