Home > Article > Web Front-end > How vue+checkbox operates data binding, acquisition and calculation
This time I will show you how to operate vue checkboxData binding and acquisition and calculation. What are the notes for vue checkbox operation data binding, acquisition and calculation, as follows This is a practical case, let’s take a look at it.
html
<input type='checkbox' v-model='checkboxModel' :value='z.coach_id+"-"+z.amount' :i="dianji" @click="lll">
First CheckBox
<span><input type='checkbox' v-model='checked' v-on:click='checkedAll'><span class="select-all">全选</span></span>
the second
Definition
return { dianji:'12', list: [], value:{}, value1:{}, checkAll: false, checkArr:[], checkboxModel:[], wodeshi:'0', checked:false } lll: function(){ var self = this; var sum=0; setTimeout(function(){ for(var x in self.checkboxModel){ sum += parseInt(self.checkboxModel[x].split('-')[1]) } self.wodeshi=sum; },0) // console.log(self.checkboxModel) }, checkedAll: function() { var _this = this; if (this.checked) {//实现反选 _this.checkboxModel = []; }else{//实现全选 _this.checkboxModel = []; _this.list.forEach(function(z) { _this.checkboxModel.push(z.coach_id+'-'+z.amount); }); } if(_this.checkboxModel.length==0){ this.wodeshi=0; // console.log(_this.checkboxModel); }else { var self =this; var sum =0; for(var x in self.checkboxModel){ sum += parseInt(self.checkboxModel[x].split('-')[1]) } self.wodeshi=sum; } },
I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!
Recommended reading:
How NodeJS implements WebSocket function
What are the methods for nodeJs to connect to mysql
The above is the detailed content of How vue+checkbox operates data binding, acquisition and calculation. For more information, please follow other related articles on the PHP Chinese website!