Change console.log message color

后端 未结 7 701
我寻月下人不归
我寻月下人不归 2021-01-31 03:12

Is there a way to do something like:

console.log(\"hello world\", \'#FF0000\')

in Chrome/Safari or Firefox ?

7条回答
  •  鱼传尺愫
    2021-01-31 03:17

    You can add functions to the object console, for example I use this function for success

    console.success = (message) => { 
      console.log('%c ' + message, 'color: green; font-weight:bold') 
    }
    
    console.success('I am a successfull message')
    

提交回复
热议问题