设置console文字颜色
function log(text, color) {
var t = ""; var c = [];
if (text instanceof Array) {
for (var i = 0; i < text.length; i++) {
t += "%c" + text[i];
}
c.push(t);
for (var i = 0; i < text.length; i++) {
if (typeof (color[i]) != "undefined")
c.push("color:" + color[i]);
else
c.push("color:df");
}
console.log.apply(console, c);
}
else {
console.log("%c" + text, "color:" + color);
}
}
log(["QQ",":","3504725309"],["red","#000000","green"]);
占位符
console.log("hi,%s,%d","Df",666)