如何在 Chrome 控制台中显示完整对象? [英] How to show full object in Chrome console?

查看:45
本文介绍了如何在 Chrome 控制台中显示完整对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

var functor=function(){//测试}函子.prop=1;控制台日志(函子);

这里只显示函子的函数部分,不能在控制台显示函子的属性.

解决方案

使用 console.dir() 输出一个可以点击的可浏览对象,而不是 .toString() 版本,像这样:

console.dir(functor);

<块引用>

打印指定对象的 JavaScript 表示.如果记录的对象是 HTML 元素,则打印其 DOM 表示的属性 [1]

<小时>

[1] https://developers.google.com/web/tools/chrome-devtools/debug/console/console-reference#dir

var functor=function(){
    //test
}

functor.prop=1;

console.log(functor);

this only show the function part of the functor, cannot show the properties of the functor in console.

解决方案

Use console.dir() to output a browse-able object you can click through instead of the .toString() version, like this:

console.dir(functor);

Prints a JavaScript representation of the specified object. If the object being logged is an HTML element, then the properties of its DOM representation are printed [1]


[1] https://developers.google.com/web/tools/chrome-devtools/debug/console/console-reference#dir

这篇关于如何在 Chrome 控制台中显示完整对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆