numPlass++;
let names = [];
var set = cart_item.childNodes[numPlass].innerHTML;
names.push(set);
let local = JSON.stringify(names);
localStorage.setItem('name' ,local)
它只会显示最后一个,并且不会在数组中放置多个
答案 0 :(得分:0)
此
let names = JSON.parse(localStorage.getItem('name'))|| [];
var set = cart_item.childNodes[numPlass].innerHTML;
names.push(set);
localStorage.setItem('name', JSON.stringify(names));