Vue实现购物车基本功能
(编辑:jimmy 日期: 2024/11/6 浏览:3 次 )
Vue实现购物车商品 加、减、单选、全选、删除、价格更新等功能
Dome和Vue代码
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>商城</title> <link rel="stylesheet" href="./css/common.css" > <link rel="stylesheet" href="./css/cart.css" > </head> <body> <div id="main"> <div class="container"> <div id="cart"> <h1>购物车</h1> <form action="#" method="post"> <table class="form"> <thead> <tr> <th width="8%">选择</th> <th width="50%">商品</th> <th width="13%">单价(元)</th> <th width="15%">数量</th> <th width="14%">金额(元)</th> </tr> </thead> <tbody id="cart-goods-list"> <tr v-for="cart in productList"> <td> <input type="checkbox" name="good-id" :value="1" v-model="cart.select"> </td> <td class="goods"> <div class="goods-image"> <img v-bind:src="/UploadFiles/2021-04-02/cart.pro_img">购物车部分CSS代码
@charset "utf-8"; #main{ padding: 30px 0px; } #cart{ background: #FFFFFF; padding: 40px; } #cart h1{ line-height: 40px; padding: 0px 0px 10px 0px; } table.form{ border-collapse: collapse; empty-cells: show; margin: 20px 0px; padding: 0px; table-layout: fixed; width: 100%; } table.form th, table.form td{ border-bottom: 1px solid #DDDDDD; padding: 15px 10px; text-align: left; } table.form{ border-top: 3px solid #DDDDDD; } .goods .goods-image img{ border: 1px solid #DDDDDD; float: left; height: 100px; margin: 0px 20px 0px 0px; } .goods .goods-information{ float: left; } .goods .goods-information ul{ color: #666666; font-size: 12px; line-height: 20px; margin:10px 0px 0px 0px; } .price, .amount, #total-amount{ color: #E00000; } #total-amount{ font-size: 22px; } .price em, .amount em, #total-amount em{ font-style: normal; } .combo .combo-minus, .combo .combo-value, .combo .combo-plus{ background: #FFFFFF; border: 1px solid #DDDDDD; color: #333333; float: left; font-weight: bold; margin: 0px; outline: none; text-align: center; } .combo .combo-minus, .combo .combo-plus{ font-size: 16px; height: 26px; line-height: 26px; padding: 0px; width: 24px; } .combo .combo-value{ border-left: none; border-right: none; height: 20px; line-height: 20px; padding: 2px; width: 40px; } #cart-delete{ margin-left: 20px; } #settlement{ background: #E00000; border: none; color: #FFFFFF; float: right; font-size: 16px; height: 40px; line-height: 40px; margin: 0px; outline: none; padding: 0px; width: 160px; }注:CSS样式代码由于太多上面没有给全,只给了主要代码。小伙伴们可以根据实际情况修改样式
关于vue.js组件的教程,请大家点击专题vue.js组件学习教程进行学习。
更多vue学习教程请阅读专题《vue实战教程》
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
下一篇:vue实现顶部菜单栏