- log的二次封装
- 具体代码
function print(info) {
const contentArr = info.map(info => info.content);
const styleArr = info.map(info => info.style).map(style => style.join(""));
console.log(`%c${contentArr.join('%c')}`, ...styleArr)
}
print([
{ content: "Hello", style: ['font-size: 20px;', 'color: red;']},
{ content: "World", style: ['font-size: 14px;', 'color: #3270f1;']}
]);
标签:info,map,style,console,log,样式,content
From: https://www.cnblogs.com/bingquan1/p/17661081.html