【发布时间】:2020-11-30 17:38:30
【问题描述】:
这里我有 onclick 函数,它可以从 detailss 数组中获取 Product_id、Product_name 和 Price。我正在使用本地存储数组愿望清单存储这个值。
现在我被困在更新本地存储阵列愿望清单中的数量, 如果 productid 已经存在于本地存储中,我需要添加数量。
addToCart(Product_id){
var name=[{
Product_id:this.detailss[0].Product_id,
Product_name:this.detailss[0].Product_name,
Price:this.detailss[0].Price,
Quantity:"",
}];
var a = JSON.parse(localStorage.getItem('wishlist')) || [];
a.push(name);
localStorage.setItem('wishlist', JSON.stringify(a));
console.log(Product_id);
}
提前致谢。
【问题讨论】:
标签: angular ionic-framework typescript1.8