home-

你说的都对,我不跟你计较。

定义一个名字为removeByValue的js文件

 

export function removeByValue(arr, attr, value) {// 1数组 2属性 3属性值
  var index = -1;
  for (var i in arr) {
    if (arr[i][attr] == value) {
      index = i;
      break;
    }
  }
if( index != -1 ){
    arr.splice(index, 1);
  }
  
}
export default removeByValue;

 

 

 

main.js引入

import removeByValue from "./common/removeByValue/index.js";
Vue.prototype.$removeByValue = removeByValue;
//给它的原型添加一个名为$removeByValue的属性

使用:

this.$removeByValue(指定的数组, "数组中要删除的属性", "数组中要删除的属性值");
this.$removeByValue(this.columns12, "title", "研究院名称");

分类:

技术点:

相关文章:

  • 2021-10-16
  • 2021-06-16
  • 2022-12-23
  • 2021-10-25
  • 2022-12-23
  • 2021-12-29
  • 2021-10-25
  • 2021-12-04
猜你喜欢
  • 2022-12-23
  • 2021-10-16
  • 2021-09-27
  • 2021-07-27
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案