我想知道我是否可以清除控制台的一些命令。

Console.log(),可以打印…是否有清除控制台的命令?

我已经尝试console.log(控制台);得到下面这个函数。

assert: function assert() { [native code] }
constructor: function Console() { [native code] }
count: function count() { [native code] }
debug: function debug() { [native code] }
dir: function dir() { [native code] }
dirxml: function dirxml() { [native code] }
error: function error() { [native code] }
group: function group() { [native code] }
groupEnd: function groupEnd() { [native code] }
info: function info() { [native code] }
log: function log() { [native code] }
markTimeline: function markTimeline() { [native code] }
profile: function profile() { [native code] }
profileEnd: function profileEnd() { [native code] }
time: function time() { [native code] }
timeEnd: function timeEnd() { [native code] }
trace: function trace() { [native code] }
warn: function warn() { [native code] }
__proto__: Object

我想没有办法清理控制台……但我希望有人对我说……]


当前回答

Chrome -在聚焦控制台输入时按CTRL + L。

Firefox -在控制台输入中清除()。

Internet Explorer -在聚焦控制台输入时按CTRL + L。

边缘-在聚焦控制台输入时按CTRL + L。

祝你有愉快的一天!

其他回答

一个方便的编译,用于以编程方式清除控制台的多个答案(从脚本,而不是控制台本身):

if(console._commandLineAPI && console._commandLineAPI.clear){
    console._commandLineAPI.clear();//clear in some safari versions
}else if(console._inspectorCommandLineAPI && console._inspectorCommandLineAPI.clear){
    console._inspectorCommandLineAPI.clear();//clear in some chrome versions
}else if(console.clear){
    console.clear();//clear in other chrome versions (maybe more browsers?)
}else{
    console.log(Array(100).join("\n"));//print 100 newlines if nothing else works
}

铬:

console._commandLineAPI.clear();

Safari:

console._inspectorCommandLineAPI.clear();

你可以创建自己的变量,它可以在以下两种情况下工作:

if (typeof console._commandLineAPI !== 'undefined') {
    console.API = console._commandLineAPI;
} else if (typeof console._inspectorCommandLineAPI !== 'undefined') {
    console.API = console._inspectorCommandLineAPI;
} else if (typeof console.clear !== 'undefined') {
    console.API = console;
}

在此之后,您可以简单地使用console.API.clear()。

按CTRL+L快捷键清除日志,即使您选择了保存日志选项。 希望这能有所帮助。

你可以使用

console.clear();

如果您正在使用javascript编码。

否则,您可以使用CTR+L清除控制台编辑器。

在Mac上,你也可以像在终端中一样使用⌘+K。