template代码:
script部分:
var proData = [{
"name": "j1ax"
},{
"name": "j2ax"
},{
"name": "j3ax"
},{
"name": "j4ax"
}]
export default {
name: 'hello',data() {
return {
proData: proData,selectArr: []
}
},created() {
this.$http.get('/api/home').then(function(response) {
response = response.body;
this.proData = response.data;
})
},methods: {
del() {
let arr = [];
var len = this.proData.length;
for (var i = 0; i < len; i++) {
if (this.selectArr.indexOf(i)>=0) {
console.log(this.selectArr.indexOf(i))
}else{
arr.push(proData[i])
}
}
this.proData = arr;
this.selectArr = []
},selectAll(event) {
var _this = this;
console.log(event.currentTarget)
if (!event.currentTarget.checked) {
this.selectArr = [];
} else { //实现全选
_this.selectArr = [];
_this.proData.forEach(function(item,i) {
_this.selectArr.push(i);
});
}
}
}
}
以上所述是小编给大家介绍的使用vue.js实现checkBox的全选和多个的删除功能。编程之家 jb51.cc 收集整理的教程希望能对你有所帮助,如果觉得编程之家不错,可分享给好友!感谢支持。
原文链接:https://www.f2er.com/vue/41550.html