vue里面怎么把对象转为数组

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

三种方法的打印结果如图
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容