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

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

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


当前回答

这似乎很有效:

console.clear();

其他回答

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

console._inspectorCommandLineAPI.clear()

这是可行的

总有一个好把戏:

console.log("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");

或者是上面的一个更短的变体:

console.log('\n'.repeat('25'));

这不是最优雅的解决方案,我知道:)…但作品。

对我来说,我通常只打印一个很长的“-----”分隔行,以帮助更容易阅读日志。

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

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

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

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

祝你有愉快的一天!

我认为由于“安全问题”,这已不再可用。

console.log(console)代码给出:

Console
memory: MemoryInfo
profiles: Array[0]
__proto__: Console

在代码外部,_commandLineAPI是可用的。有点烦人,因为有时我只想记录而不看到旧的输出。