一 加入缓存的大体思路
标题
疑惑点
一 Q: 这个箭头函数是什么
A :
handlePreviewImage(e){
const urls=this.GoodsInfo.pics.map(v=>v.pics_mid);
const current=e.currentTarget.dataset.url;
wx.previewImage({
current,
urls
});
},
handleCartAdd(){
let cart=wx.getStorageSync("cart")||[];
let index=cart.findIndex(v=>v.goods_id===this.GoodsInfo);
if(index===-1){
this.GoodsInfo.num=1;
cart.push(this.GoodsInfo);
}else{
cart[index].num++;
}
wx.setStorageSync("cart",cart);
wx.showToast({
title: '不是要剁手吗',
icon:"success",
mask:true
});
}