答案 0 :(得分:1)
尝试:https://github.com/icodeforlove/Console.js
或者您可以通过以下方式简单地做到这一点:
console.log("%cThis is a %cConsole.log", "background:black ; color: white", "color: red; font-size:25px");
也请查看这篇文章:http://voidcanvas.com/make-console-log-output-colorful-and-stylish-in-browser-node/
答案 1 :(得分:1)
尝试添加如下内容:
<script type="text/javascript">
const warningTitleCSS = 'color:red; font-size:60px; font-weight: bold; -webkit-text-stroke: 1px black;';
const warningDescCSS = 'font-size: 18px;';
console.log('%cStop!', warningTitleCSS);
console.log("%cThis is a browser feature intended for developers. If someone told you to copy and paste something here to enable a Facebook feature or \"hack\" someone's account, it is a scam and will give them access to your Facebook account.", warningDescCSS);
console.log('%cSee https://www.facebook.com/selfxss for more information.', warningDescCSS);
</script>
https://gist.github.com/tosbourn/f556ee09c4a551e91d1dfde2f7b254f4
答案 2 :(得分:1)
如果只需要格式化,可以执行以下操作:
console.log('%cSTOP!', 'font-size:24px;color:red;')
为了不在控制台中显示js错误,最简单,最佳实践的方法是不将其放在首位和/或捕获它们并在它们发生时进行处理。
答案 3 :(得分:0)
我在该网站上找到了一篇有关该内容的旧帖子:
How does Facebook disable the browser's integrated Developer Tools?
列出了不同的方法,但结果可能取决于浏览器。我尝试了一些,但仍可以从控制台执行,但是由于某些原因,该链接很有用。