const items = [];
Meteor.http.call("GET", url,function(error,result){
$.each(JSON.parse(result.content), function(key, value){
items.push(value)
});
});
最佳答案
Meteor.http.call
是一个带有回调的异步函数。我可以想到做你想做的快速方法如下:
const items = [];
Meteor.http.call("GET", url,function(error,result){
$.each(JSON.parse(result.content), function(key, value){
items.push(value)
});
handleItems(items);
});
function handleItems(items) {
console.log(items.length) // 1
// Do what you want with the items array here.
}
关于javascript - Meteor 中长度为 0 的非空数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42092615/