console.log显示数组对象的内容 [英] console.log showing contents of array object

查看:829
本文介绍了console.log显示数组对象的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用 console.log 来查看包含多个对象的数组的内容。但是我收到一条错误消息,说 console.log 不是对象等。我使用的是jquery 1.6.2,我的数组如下:

I have tried using console.log so I can see the content of my array that contains multiple objects. However I get an error saying console.log is not an object etc. I'm using jquery 1.6.2 and my array is like this:

filters = {dvals:[{'brand':'1', 'count':'1'},
                  {'brand':'2', 'count':'2'}, 
                  {'brand':'3', 'count':'3'}]}

console.log(filters);

我要做的是写出 array(filters )到过滤器格式的警报框(这就是我认为 console.log 所做的事情)。我该怎么办?

What I want to to do is write out the contents of array(filters) to an alert box (that's what I thought console.log did) in the filters format. How do I do that?

推荐答案

console.log 不产生任何消息框。我认为在不添加Firebug或某些等效功能的情况下,任何版本的IE(或Firefox)都无法使用它。

console.log does not produce any message box. I don't think it is available in any version of IE (nor Firefox) without the addition of firebug or some equivalent.

但是它可以在Safari和Chrome中使用。既然您提到了Chrome,我将以它为例。

It is however available in Safari and Chrome. Since you mention Chrome I'll use that for my example.

您需要打开窗口及其相应的开发者窗口。您可以通过右键单击页面上的任何元素并选择检查元素来执行此操作。您的窗口将分为两部分,开发者部分位于底部。在两个部分之间的分隔中是带有按钮的栏,最右边的按钮标记为控制台。您需要单击该按钮以切换到控制台标签。在Windows的大多数浏览器中,按F12键获取开发人员工具,在macOS上按Command + shift + I。

You'll need to open your window and its developer window counterpart. you can do this by right clicking any element on the page and selecting "Inspect element". your window will be divided in two parts, the developer part being the bottom. in the division between the two parts is a bar with buttons and the rightmost button there is labeled "console". You'll need to click that to switch to the console tab. Press F12 for developer tools in most browsers on Windows, command + shift + I on macOS.

一旦完成,您就可以与顶部加载的任何页面进行交互通过该控制台中的javascript,您 console.log 中的所有消息都将显示在此处。

Once there, you will be able to interact with whatever page is loaded on top through javascript from that console, and any messages you console.log will be displayed there.

这篇关于console.log显示数组对象的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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