我尝试这样做:
posts[fbposts[fbpost].id] = ({
name: fbposts[fbpost].from.name,
link: "http://www.facebook.com/" + fbposts[fbpost].from.id,
img: "http://graph.facebook.com/" + fbposts[fbpost].from.id + "/picture",
message: fbposts[fbpost].message,
to: ({
name: name,
link: link,
}),
created: timeDifference(Date.parse((fbposts[fbpost].updated_time))),
sortvar: (Date.parse(fbposts[fbpost].updated_time)),
comments: ({
/* looping through the comments*/
if (fbposts[fbpost].comments.count) {
for (var comment in fbposts[fbpost].comments.data) {
name: fbposts[fbpost].comments.data[comment].from.name;
link: "http://www.facebook.com/" + fbposts[fbpost].comments.data[comment].from.id;
img: "http://www.facebook.com/" + fbposts[fbpost].comments.data[comment].from.id; + "/picture";
message: fbposts[fbpost].comments.data[comment].message;
created: timeDifference(Date.parse(fbposts[fbpost].comments.data[comment].created_time));
}
}
})
});
}
但很明显,当我收到评论时,脚本会刹车,因为我不能在对象声明中运行循环和条件。我应该怎么做呢?