这篇文章主要为大家详细介绍了vue实现购物车结算功能,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
用vue做的购物车结算的功能,供大家参考,具体内容如下本文来源gao@dai!ma.com搞$代^码!网7
代码:
<!-- 占位 --> <div> <div class="product_table"> <div class="product_info">商品信息</div><div class="product_info">商品金额</div><div class="product_info">商品数量</div><div class="product_info">总金额</div><div class="product_info">编辑</div></div><div class="product_table"> <div style="width:20px;height:20px;border:1px solid black"></div><div class="product_info">{{item.productName}}</div><div class="product_info">{{item.productPrice}}</div><span>+</span><span>-</span><div class="product_info">{{item.productPrice*item.prductQty}}</div><div class="product_info">删除</div></div><div style="width:20px;height:20px;border:1px solid black;margin-top:10px"></div><div>总价格:{{totalPrice}}</div></div> .product_table{ display: flex; width: 100%; } .product_info{ flex:1; } .checked{ background-color:green; }
这个代码实现了什么?
1.在点击加减时每个产品的总价变化,所有产品的总价变化
2.选中时才会结算
3.如果全部选中了每个子项,全部选中按钮会变绿,如果有一项不选中,那么会变白
4.一般的购物车,我希望他一进来就是checked的状态,提高购买性
5.当我删除某一项时,如果这一项是已经checked了的,也要让他在计算总价时重新计算.
ps:最后一行的按钮是全部选中哦,或者是全部取消,忘记写了。
以上就是vue实现购物车结算功能的详细内容,更多请关注gaodaima搞代码网其它相关文章!