所以我正在从Excel工作簿中读取值,并试图找出如何从所述值创建构造函数。我遍历包含值的工作表对象,并将其与我的地图对象进行比较以获取相关值
const map = {
E: 'E',
F: 'F',
G: 'G',
H: 'H',
I: 'I',
J: 'J',
K: 'K',
L: 'L',
M: 'M',
N: 'N',
O: 'O',
P: 'P',
Q: 'Q',
R: 'R',
S: 'S',
T: 'T',
U: 'U'
};
for (var z in worksheet) {
if ( map[z[0]] && z[1] === '4' && z.length === 2 ) {
values[z] = worksheet[z]
}
}
目前我将值放在values对象中,但我意识到我需要将它们放入构造函数中:
function Row(fieldCode, operatorCode, reportMonth, luwCode, facilityCode, numOfWells, parishCode, openingStock, condensationProduction, transporterCode,
dispositionType, dispositionAmount, closingStock, gasProduction, luwName, orig) {
this.fieldCode = fieldCode;
this.reportMonth = reportMonth;
this.luwCode = luwCode;
this.facilityCode = facilityCode;
this.numOfWells = numOfWells;
this.parishCode = parishCode;
this.openingStock = openingStock;
this.condensationProduction = condensationProduction;
this.transporterCode = transporterCode;
this.dispositionType = dispositionType;
this.dispositionAmount = dispositionAmount;
this.closingStock = closingStock;
this.gasProduction = gasProduction;
this.luwName = luwName;
this.orig = orig;
}
我想知道如何将values对象中的值传递给构造函数?
EDIT 我正在尝试得到像这样的键/值
const values = {
fieldCode: '4451',
operatorCode: '6548',
reportMonth: '11'
...
}