我试图获取数据,数据输出到控制台,但错误发生得很顺利...
Json array vk neewsfeed!
代码:
export function ParseAttach(content){
if (content == undefined) return true;
let img = [];
let index = 0;
content.map(function(item,i){
if (item.type == 'photo' || item.type == 'graffiti'){
index++;
img[0] = index;
img[index] = item.photo.photo_604;
} else if (item.type == 'link'){
index++;
img[0] = index;
console.log(item.link.photo.photo_604);
img[index] = item.link.photo.photo_604;
}
})
}
答案 0 :(得分:0)
您不需要额外的功能。
你可以这样做:
export function ParseAttach(content){
if (content == undefined) return true;
let img = [];
let index = 0;
content.map(function(item,i){
if (item.type == 'photo' || item.type == 'graffiti'){
index++;
img[0] = index;
img[index] = item.photo.photo_604;
} else if (item.type == 'link'){
index++;
img[0] = index;
img[index] = item.link.photo && item.link.photo.photo_604;
}
})
}