_changeCounts(id, counts) { var cartData = this.getCartDataFromLocal(), hasInfo = this._isHasThatOne(id, cartData); if (hasInfo.index != -1) { if (hasInfo.data.counts > 1) { // 为什么是大于1不是大于0 ? cartData[hasInfo.index].counts += counts; } } wx.setStorageSync(this._storageKeyName, cartData); };
为什么是 if ( hasInfo.data.counts > 1 ) { ...... } 而不是 if ( hasInfo.data.counts > 0 ) { ...... } ?
购物车商品数量为1的时候, 如果想增加商品数量, if语句会被跳过