码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2020-05-25 22:24:11      阅读:178      评论:0      收藏:0      [点我收藏+]

标签:tty   div   nbsp   span   console   ons   显示   解决方案   pre   

平时工作中,时常要打印一些对象到控制台,但平常的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]的解决方案

标签:tty   div   nbsp   span   console   ons   显示   解决方案   pre   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!