【发布时间】:2020-10-03 15:00:41
【问题描述】:
虽然数组项数组中存储了多个数据,但它只显示最近添加的数据。这可能是什么原因? 提前感谢您的支持
// List items
const array_item = JSON.parse(localStorage.getItem("array_item") || "[]");
array_item.forEach(function(item,index,array){
const output = '<div class="bg-card p-2" style="font-size:14px;"><div class="container"><strong>Okunmadı olarak işaretlediğin makale:</strong> <a href="<?=PROOT?>home/details/'+item.sef_link +'">'+item.title+'</a></div></div>';
console.log(array);
document.getElementById("mark").innerHTML = output;
});
【问题讨论】:
-
您每次都在替换内容而不是追加内容!
-
我没有做任何改变它。我只是想在数组项数组中提取数据。我在哪里犯错了?
-
document.getElementById("mark").innerHTML = output每次都替换 HTML,而不是追加到它上面!
标签: javascript arrays json local-storage