[英]non empty array with length=0 in Meteor
Meteor.http.call
是一個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.
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.