为什么console.log不能在chrome中输出? [英] why does console.log not output in chrome?

查看:622
本文介绍了为什么console.log不能在chrome中输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我读了一个关于console.log做什么的查询,我读了一个答案,尝试使用它,发现尽管答案指出它在谷歌浏览器中输出到控制台,但我试过了,没有输出。



我试过这段代码:

 函数put (p){
if(window.console&& window.console.log){
console.log(p); //控制台可用
} else {
alert(p);
}
}

但是...我没有输出控制台或警报此外,.log是一个Math属性,给出了什么?

解决方案

确保在Developer Tools中的Filter控制台部分设置为全部或日志...



我有类似的经历,我看不到任何我的console.log输出,这是因为控制台设置为只在错误上过滤...所有日志条目都存在 - 它们只是不可见。



奖励标记:您也可以按Ctrl +单击以选择多个过滤器(例如错误+日志)。

Recently I read a query about "What does console.log do" and I read an answer, tried using it and found that despite the answer stating that it outputs to the console in googles browser, I just tried it and I get no output.

I did try this code:

function put(p){
if ( window.console && window.console.log ) {
        console.log(p); // console is available
    }else{
        alert(p);
    }
}

BUT... I get neither console output or alert and furthermore .log is a Math property, what gives with that?

解决方案

Make sure that in the Developer Tools the Filter in the console section is set to All or Logs...

I had a similar experience where I couldn't see any of my console.log output and it was because the console was set to filter on Errors only... All the log entries were there - they just weren't visible.

Bonus marks: you can also Ctrl + Click to select multiple filters (Errors + Logs for example).

这篇关于为什么console.log不能在chrome中输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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