首页 > 其他 > 详细

对象object在console.log时,显示[Object]的解决方案

时间:2020-05-25 23:05:28      阅读:72      评论:0      收藏:0      [点我收藏+]

平时工作中,时常要打印一些对象到控制台,但平常的console.log只能看到最外的一层,里边的都会以[Object]隐藏掉 如:

[ { id: ‘300760‘, data: [ [Object], [Object] ] },
  { id: ‘300529‘,
    data:
     [ [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object] ] },
 ]

可以用console.dir(object, {depth:null}} 来显示全部

[ { id: ‘300760‘,
    data:
     [ { code: ‘300760‘, season: ‘2018-12-31‘, profit: 369067 },
       { code: ‘300760‘, season: ‘2019-12-31‘, profit: 461498 } ] },
  { id: ‘300529‘,
    data:
     [ { code: ‘300529‘, season: ‘2011-12-31‘, profit: 7100 },
       { code: ‘300529‘, season: ‘2012-12-31‘, profit: 9361 },
       { code: ‘300529‘, season: ‘2013-12-31‘, profit: 12099 },
       { code: ‘300529‘, season: ‘2014-12-31‘, profit: 14566 },
       { code: ‘300529‘, season: ‘2015-12-31‘, profit: 19390 },
       { code: ‘300529‘, season: ‘2016-12-31‘, profit: 19413 },
       { code: ‘300529‘, season: ‘2017-12-31‘, profit: 24517 },
       { code: ‘300529‘, season: ‘2018-12-31‘, profit: 35224 },
       { code: ‘300529‘, season: ‘2019-12-31‘, profit: 52199 } ] },
 ]

可以看到相当pretty了

 

对象object在console.log时,显示[Object]的解决方案

原文:https://www.cnblogs.com/yuanzheng/p/12957844.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!