How to hide source of Log messages in Console?

前端 未结 2 1493
滥情空心
滥情空心 2021-01-31 16:27

When outputting messages into the console, the source is also displayed (in Chrome Developer Tools it\'s on the right):

console.log(\"Foo\");                             


        
相关标签:
2条回答
  • 2021-01-31 17:17

    They are using setTimeout to detach from the source:

    setTimeout(console.log.bind(console, '\n%c' + s[0], s[1]));
    
    0 讨论(0)
  • 2021-01-31 17:19

    for those who are still looking for this, you can use something like

    function consoleWithNoSource(...params) {
      setTimeout(console.log.bind(console, ...params));
    }
    
    consoleWithNoSource("Helloo....!")

    0 讨论(0)
提交回复
热议问题