今天中午廢了一會時間,總算把項目中的購物車的單選、全選、以及實現(xiàn)數(shù)據(jù)的動態(tài)顯示做出來了,給小白分享一下我個人一個解決辦法:

購物車的基本頁面如下:
先說實現(xiàn)的總體思路
這是我個人的思路,具體代碼實現(xiàn)如下:
html:
<div id="a" class="container">
<table class="table table-hover" v-if="list.length">
<thead>
<tr>
<th><input type="checkbox" id="box" @click="checkAll" v-model="checkall" /></th>
<th>圖片</th>
<th>商品名</th>
<th>數(shù)量</th>
<th>單價</th>
<th>總金額</th>
<th>加入時間</th>
<th>刪除</th>
</tr>
</thead>
<tbody>
<tr v-for="(dateil,index) in list" :key="index">
<td><input type="checkbox" class="checkbox" v-model="checked" @click="select(dateil.detailId,dateil.detailProductprice,dateil.detailProductnum)" :value="dateil.detailId" /></td>
<td><a @click="goShop(dateil.detailProductId)" ><img v-bind:src="web_server_static+dateil.product.productPhoto"></a></td>
<td><a @click="goShop(dateil.detailProductId)" >{{dateil.product.productName}}</a></td>
<td>{{dateil.detailProductnum}}</td>
<td>{{dateil.detailProductprice}}</td>
<td>{{dateil.detailProductprice*dateil.detailProductnum}}</td>
<td>{{dateil.detailDatetime}}</td>
<td>
<button type="button" id="but" @click="del(dateil.detailId)" class="btn btn-danger">刪除</button>
</td>
</tr>
</tbody>
</table>
<div v-else >購物車空空如也,請先去購買商品~</div>
<div id="label_btn">
<span><label>已選商品<a>{{count}}</a>件,共</a>¥{{price}}</a>元 數(shù)組{{checked}}</label>
</span>
<span><button type="button" id="btn-close" @click="jiesuan()" class="btn btn-danger">結(jié)算</button></span>
</div>
<!--結(jié)算按鈕-->
</div>
本文標(biāo)題:Vue實現(xiàn)購物車的全選、單選、顯示商品價格代碼實例-創(chuàng)新互聯(lián)
本文路徑:http://www.chinadenli.net/article28/deiccp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供靜態(tài)網(wǎng)站、網(wǎng)站策劃、動態(tài)網(wǎng)站、營銷型網(wǎng)站建設(shè)、網(wǎng)站導(dǎo)航、用戶體驗
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容