第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

有誰能在這個基礎(chǔ)上完善這個功能???我是十分感謝了

有誰能在這個基礎(chǔ)上完善這個功能???我是十分感謝了

西蘭花偉大炮 2017-12-11 23:53:42
<!DOCTYPE?html> <html> ????<head> ????????<meta?charset="utf-8"?/> <title>vue購物車</title> <link?rel="stylesheet"?> ????</head> ????<body> ????????<div?id="app"?v-cloak> <template?v-if="list.length"> <table?class="table?table-hover?talbe-striped"> <tr><input?type="checkbox"?@click="checkedAll"?v-model="allCheck"></tr> <tr>{{allCheck}}{{checkModel}}</tr> <tr>商品名稱</tr> <tr>單價</tr> <tr>數(shù)量</tr> <tr>操作</tr> <tr?v-for="(item,index)?in?list"> <td><input?type="checkbox"?v-model="list[index].isChecked"?@click="isAllCheck"></td> <td>{{item.id}}</td> <td>{{item.name}}</td> <td>{{item.price}}</td> <td>{{item.isChecked}}</td> <td> <button?@click="reduceNum(index)">-</button> {{item.count}} <button?@click="addNum(index)">+</button> </td> <td> <button?@click="removeItem(index)">移除</button> </td> </tr> </table> <div>總價:¥{{totalPrice}}</div> </template> <div?v-else>購物車為空,現(xiàn)在去選購吧!</div> ????????</div> ????</body> ???? <script?type="text/javascript"?src="https://cdn.bootcss.com/vue/2.5.3/vue.min.js"></script> <script?src="index.js"></script> </html>var?app?=?new?Vue({ el:"#app", data:{ allCheck:false, list:[ {id:1,name:'小米6',price:2499,count:2,isChecked:false}, {id:2,name:'充電寶',price:25,count:6,isChecked:false}, {id:3,name:'榮耀10',price:2699,count:4,isChecked:false}, {id:4,name:'蘋果X',price:8499,count:3,isChecked:false}, ], checkModel:0 }, computed:{ totalPrice:function(){ var?total?=?0; for(var?i?=?0;i?<?this.list.length;i++){ var?item?=?this.list[i]; if(item.isChecked){ total?+=item.price?*?item.count;} } return?total.toString().replace(/\B(?=(\d{3})+$)/g,','); } }, methods:{ reduceNum:function(index){ if(this.list[index].count?===?1)?return; this.list[index].count--; }, addNum:function(index){ this.list[index].count++; }, removeItem:function(index){ this.list.splice(index,1); }, checkedAll:function(){ for(var?i?=?0;i?<?this.list.length;i++){ this.list[i].isChecked?=?!this.allCheck; } }, isAllCheck:function(){ } } })需要添加一個全選功能,只有勾選的商品計入總價,所有商品勾選上,全選也勾選
查看完整描述

2 回答

?
堂堂堂堂糖糖糖童鞋

TA貢獻101條經(jīng)驗 獲得超58個贊

isAllCheck:?function?()?{
??this.$nextTick(_?=>?{
????this.allCheck?=?this.list.length?===?this.list.filter(item?=>?{
??????return?item.isChecked
????}).length
??})
}


查看完整回答
反對 回復(fù) 2017-12-12
?
堂堂堂堂糖糖糖童鞋

TA貢獻101條經(jīng)驗 獲得超58個贊

Vue 做這個功能應(yīng)該挺簡單的

查看完整回答
反對 回復(fù) 2017-12-12
  • 2 回答
  • 0 關(guān)注
  • 2068 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號