zoukankan      html  css  js  c++  java
  • ultra-console

    
    console.__proto__.styleText = function (option) {
    
      if (!option) {
        console.groupCollapsed('请输入option');
        console.table({
          text: '文本',
          style: '样式',
        });
        console.table({
          text: '字符串数组',
          style: '样式字符串数组',
        });
        console.groupEnd('请输入option');
        return;
      }
    
      if (!option || !option.text || !option.style) {
        return;
      }
    
      if (typeof option.text === 'string' && typeof option.style === 'string') {
        console.log(`%c${option.text}`, option.style);
      }
    
      if (Array.isArray(option.text) && Array.isArray(option.style)) {
    
        let txt = '';
      
        option.text.forEach((text) => {
          txt += `%c${text}`;
        });
      
        console.log(txt, ...option.style)
      }
    }
    console.log(`%chello%cworld`,`
      color: #fff;
      background: #000;
    `,`
      color: #fff;
      background: blue;
    `);
    
    console.styleText({
      text: ['hello','world','hi'],
      style: [`
        color: #fff;
        background: #000;
        padding: 5px;
      `,`
        color: #fff;
        background: blue;
        padding: 5px;
      `,`
        color: #fff;
        background: green;
        padding: 5px;
      `],
    });
    
    console.styleText({
      text: 'hello',
      style: `
        color: #fff;
        background: blue;
        padding: 5px;
      `,
    });
    
  • 相关阅读:
    毕业了!
    mesos无执行器启动docker
    docker run option
    maintenance
    virtualenv
    multi role
    排序之插入排序
    DLU-1064 美声葱
    codeforces-1025 A Doggo Recoloring
    codeforces-1027 C Minimum Value Rectangle
  • 原文地址:https://www.cnblogs.com/dkplus/p/9908246.html
Copyright © 2011-2022 走看看