工具类:多个数组组合成对象数组形式
this.paramName = this.queryObj.paramName.split("|");
this.paramValues = this.queryObj.paramValue.split("|");
this.referenceRange = this.queryObj.referenceRange.split("|");
const isEmpty = xs => xs.length === 0;
const head = ([x, ...xs]) => x;
const tail = ([x, ...xs]) => xs;
const map = (f, ...xxs) => {
let loop = (acc, xxs) => {
if (xxs.some(isEmpty)) return acc;
else return loop([...acc, f(...xxs.map(head))], xxs.map(tail));
};
return loop([], xxs);
};
let result = map(
(name, value, cope) => ({ name, value, cope }),
this.paramName,
this.paramValues,
this.referenceRange
);
console.log(result)