我正在尝试从我的Drupal节点检索图像,但我不断定义'0'。我从我自己的Drupal页面获取文章。
for(var i =0;i<news.length;i++)
{
var article =
[
news[i].node.Nid + '-'+ lang,
newsCount,
d.getMilliseconds(),
news[i].node.title,
news[i].node.date,
news[i].node.Featured_image[0].src,
lang,
news[i].node.Body
];
var url = decodeURIComponent(news[i].node.Featured_image);
ImgCache.cacheFile(url);
articles.push(article);
}
所以我试过了......
for(var i =0;i<news.length;i++)
{
if (typeof news[i].node.Featured_image == undefined)
{
news_image = news[i].node.Featured_image;
}
else
{
news_image = image;
}
var article =
[
news[i].node.Nid + '-'+ lang,
newsCount,
d.getMilliseconds(),
news[i].node.title,
news[i].node.date,
news_image,
lang,
news[i].node.Body
];
var url = decodeURIComponent(news_image);
ImgCache.cacheFile(url);
articles.push(article);
}
但似乎所有图像都未定义。不知道为什么。希望你能帮帮我。