How to realize the function of multiple selection of goods by vue
This article mainly explains "vue how to achieve commodity multi-selection function", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "vue how to achieve commodity multi-selection function" bar!
The specific code is as follows
Vue implementation to achieve full selection, settlement * {margin: 0; padding: 0; list-style: none;} # app {width: 80%; margin: auto;} .wrap {width: 100%; margin: auto;} .shangjia {font-size: 20; font-weight: bold; color: # 000; height: 36px; line-height: 36px Inpu {margin-right: 10px; margin-left: 10px;} .all _ list {padding-top: 10px; width: 100%; margin: auto; background: # bbb;} .list _ item {width: 80%; display: flex; justify-content: flex-start; position: relative; margin: 3px 0; padding: 6px 0;} img {display: inline-block;} .list _ box {display: inline-block }. List_img_tit_price {display:inline-flex; align-content:space-between;}. List_img {width: 100px; height: 100px;} .list_tit_price {display: flex; flex-flow: column; margin-left:10px; font-size: 16px; justify-content: space-between;} .total {display:inline-flex; flex-wrap: row; float: right; margin-top: 60px; margin-left: 20px }. Num_cancle,.num_add {font-size: 20px; font-weight: bolder; margin:0 2px; padding: 1PX; line-height: 36px;} .num_cancle:hover,.num_add:hover {cursor: pointer;}. Num_total {width:30px; text-align: center; font-weight: bold;} .result {float: right; display: inline-flex;} .heji {margin:0 12px; padding:3px;} .jisuan_btn {color: # fff Background: # f30; font-size: 18px; font-weight: bold; padding: 3px; border-style: none;} Select all merchandise
{{item.title}} ¥{{item.price}}-+ Total of all: {{amountPrice}} To settle ({{sumTotal}}) const vm = new Vue ({el: "# app") Data: {allList: [{title: "[first] the water of the Yellow River comes from the sky Src:'./img/1.jpg', price:880, order:1, id:0}, {title: [second] the water of the Yellow River comes from the sky. Src:'./img/2.jpg', price:881, order:1, id:1}, {title: [third] the water of the Yellow River comes from the sky. Src:'./img/3.jpg', price:882, order:1, id:2}, {title: [fourth] the water of the Yellow River comes from the sky. Src:'./img/4.jpg', price:883, order:1, id:3}, {title: [fifth] the water of the Yellow River comes from the sky. Src:'./img/5.jpg', price:884, order:1, id:4}, {title: [sixth] the water of the Yellow River comes from the sky. Src:'./img/6.jpg', price:885, order:1, id:5},]}, methods: {controlNum (temp,index) {if (temp=== "add") {this.allList.order + + } else {if (this.allList.order el.checked)}, amountPrice () {let price = 0; this.selectTotal.forEach (el = > {price + = el.price * el.order}) return price;}, sumTotal () {let total=0; for (let I = 0; I)
< this.selectTotal.length; i ++){ total += this.selectTotal[i].order; } return total; }, checkedClick(e){ return e; }, checkedAll:{ get(){ return this.allList.every(el=>El.checked)}, set (val) {this.allList.forEach (el= > el.checked=val)}) vm.allList.forEach (el= > vm.$set (el, "checked", false))
Not all selected
Select all
Thank you for your reading, the above is the content of "how to achieve the multi-selection function of vue". After the study of this article, I believe you have a deeper understanding of how to achieve the multi-selection function of vue, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!