“JS Colored Console Log” Code-Antworten

JS -Konsolenprotokoll mit Farbe

console.log('%c Oh my heavens! ', 'background: #222; color: #bada55');
If-dev

JS Colored Console Log

/**
 * @param {string} text text to return
 * @param {string} color enums: [black, red, green, yellow, blue, magenta, cyan, white]
 * @returns colored text
 */
const colorConsoleText = (text, color = 'black') => {
    const colors = {
        black: "\x1b[30m",
        red: "\x1b[31m",
        green: "\x1b[32m",
        yellow: "\x1b[33m",
        blue: "\x1b[34m",
        magenta: "\x1b[35m",
        cyan: "\x1b[36m",
        white: "\x1b[37m",
        console_color: '\x1b[0m'
    }
    const coloredText = `${colors[color]}${text}${colors.console_color}`
    return coloredText
}
Tough Tortoise

JS Console.log Farbe

console.log('%c My txt ', 'My css');

// Example
console.log('%c Hello world ', 'background: #222; color: #bada55');
Attractive Ape

JavaScript colorisierte Konsole.log

console.log(
  'Nothing here %cHi Cat %cHey Bear', // Console Message
  'color: blue',
  'color: red', // CSS Style
);
Pudochu

JavaScript console.log Farben

console.log('%c Hello World','color:red;border:1px solid dodgerblue');
Harry Fahringer III

Ähnliche Antworten wie “JS Colored Console Log”

Fragen ähnlich wie “JS Colored Console Log”

Weitere verwandte Antworten zu “JS Colored Console Log” auf JavaScript

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen