//获取本地存储的商品
let preserveArr = JSON.parse(localStorage.getItem("carts"));
const addCard = (shops: Object) => {
localStorage.setItem("carts", JSON.stringify([shops])); // []
// if (preserveArr) {
// let currentInfo = preserveArr.find((el) => {
// return el.id === shops.id;
// });
// if (currentInfo) {
// currentInfo.num = currentInfo.num + 1;
// localStorage.setItem("carts", JSON.stringify(preserveArr));
// } else {
// shops.num = 1;
// localStorage.setItem("carts", JSON.stringify([shops, ...preserveArr]));
// }
// }
}
11-12
193
193
08-01
228
228
11-11
1266
1266

被折叠的 条评论
为什么被折叠?



