js delete the specified attribute array

You're all right, I do not care about you.

Define a name for the js file removeByValue of

export function removeByValue (arr, attr, value) {// 1 second attribute property value array 3
  was index = 0;
  for (var i in arr) {
    if (arr[i][attr] == value) {
      index = i;
      break;
    }
  }
  arr.splice(index, 1);
}
export default removeByValue;

main.js introduced

import removeByValue from "./common/removeByValue/index.js";
Vue.prototype.$removeByValue = removeByValue;
// add a property called $ removeByValue to its prototype

use:

. This $ removeByValue (specified array "array property to delete", "array to delete attribute values");
. This $ removeByValue (this.columns12, "title", "Institute name");

Guess you like

Origin www.cnblogs.com/home-/p/12053668.html