请问各位大神,为什么我的部分代码有的时候会不执行?比如如下代码中的 console.log这句
Page({
data: {
ne:[1,2,3],
markers: [
]
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
const app = getApp()
const db = wx.cloud.database()
db.collection('tingdianxinxi').where({
tp: "停电"
}).get({
success: function (res) {
app.globalData.ne.push(res.data)
}
})
db.collection('tingdianxinxi').where({
tp: "停电"
}).count({
success: function (res) {
app.globalData.total = res.total
for (var i = 0; i < app.globalData.total; i++) {
app.globalData.marker_new.push({
iconPath: "/resources/others.png",
id: i,
latitude: app.globalData.ne[1][i].location.latitude,
longitude: app.globalData.ne[1][i].location.longitude,
width: 50,
height: 50
})
}
console.log(app.globalData.marker_new)
}
})
var that=this
that.setData({
ne:app.globalData.ne,
markers:app.globalData.marker_new
})
wx.getLocation({
type: 'wgs84',
success(res) {
that.setData({
latitude: res.latitude,
longitude: res.longitude,
})
}
})
},
js文件如上,为什么 console.log(app.globalData.marker_new)这句有时候编译后会输出有时候又不输出?