data里面设置的数组如下:
data() {
return {
sendSingleData:[{
readOrWrite: 1,
motherBoard: 1,
daughterBoard:1,
laserDrivenPower:1,
laserPower:1,
workingMode:1,
modulationModeIntensity:1,
constantCurrentModeIntensity:1,
modulationFreq:1,
},{
readOrWrite: 2,
motherBoard: 2,
daughterBoard:2,
laserDrivenPower:2,
laserPower:1,
workingMode:1,
modulationModeIntensity:1,
constantCurrentModeIntensity:1,
modulationFreq:1,
}]
};
},
在函数内执行遍历参数且打印出来:
for(let aaa of sendSingleData){
console.log(aaa);
console.log(Object.keys(aaa))
console.log(Object.values(aaa));
}
如图所示,三种方法打印的内容区别:
console.log(aaa);
打印的是对象
console.log(Object.keys(aaa))
打印的是数组里面的key
console.log(Object.values(aaa));
打印的是数组里面的value