一 加入緩存的大體思路
標題
疑惑點
一 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
});
}