搜索关键字:

{{slot.row.name}}

表格操作

批量删除

data() {return{

keyword:'',

selections: [],

urls: [{

name:"新浪",

url:"http://www.sina.com",

type:"资讯",

country:"中国"},

{

name:"腾讯",

url:"http://www.tencent.com",

type:"聊天",

country:"中国"},

{

name:"谷歌",

url:"http://www.google.com",

type:"资讯",

country:"美国"},

{

name:"韬睿",

url:"http://www.51i-star.com",

type:"教育",

country:"中国"}

]

};

},

methods: {

del(row){this.$confirm("确定要删除吗?", "删除").then(action=>{/*this.urls.some((item, i) =>{

if(item.name == row.name){

this.urls.splice(i, 1)

return true;

}

})*/

var index = this.urls.findIndex(item =>{if(item.name ==row.name){return true;

}

})this.urls.splice(index, 1)

});

},select(selections, row) {this.selections =selections;

},

batchDelete() {this.$confirm("确定要删除吗?", "删除")

.then(action=>{for (var i = this.urls.length - 1; i >= 0; i--) {for (var j = this.selections.length - 1; j >= 0; j--) {if (this.urls[i].name == this.selections[j].name) {this.urls.splice(i, 1);break;

}

}

}

})

.catch(error =>{

alert(error);this.$message('删除取消');

});

},

search(keyword){/*var newList = []

this.urls.forEach(item =>{

if(item.name.indexOf(keyword) != -1){

newList.push(item)

}

})

return newList*/

return this.urls.filter(item =>{if(item.name.includes(keyword)){returnitem

}

})

}

}

}

Logo

前往低代码交流专区

更多推荐