/**
* chagearronetwoone
* 把兩個數(shù)組相同對象key值的元素用第二個數(shù)組替換調(diào)第一個數(shù)組,前提第一個數(shù)組的元素的key值完全包含第二個數(shù)組的,且第一個數(shù)組元素與第二個不同的全部都改為--
* var onearr = [{ key1: "--" },{ key2: "a" },{ key3: "b" },{ key4: "7" },{ key5: "88" }];
* var twoarr = [{ key2: "aqqqqq" }, { key5: "88qqqq" }];
* flag="--"
* flag 為 不用第二個數(shù)組地替換的值的符號
* 替換后為onearr = [{ key1: "--" },{ key2: "aqqqqq" },{ key3: "--" },{ key4: "--" },{ key5: "88qqqq" }];
*/
chagearronetwoone (arr, arr2, flag) {
let aa = [];
let bb = [];
arr.map((item, index) => {
bb.push(index);
});
arr2.map(item2 => {
arr.map((item1, index) => {
if (Object.keys(item1)[0] === Object.keys(item2)[0]) {
aa.push(index);
}
});
});
aa.map((item, index) => {
this.$set(arr, item, arr2[index]);
});
let cc = this.getArrDifference(aa, bb);
cc.map(ite => {
this.$set(arr, ite, flag);
});
return arr;
},