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;
      `,
    });
    
  • 相关阅读:
    crontab修改默认编辑器
    phpstorm license 解决
    获从2017-2 到现在所有月份;
    获取所在月第一天和最后一天
    EF相关报错
    EF延迟加载LazyLoading
    EF性能优化
    Redis
    搜索服务器Elasticsearch
    Nosql
  • 原文地址:https://www.cnblogs.com/dkplus/p/9908246.html
Copyright © 2011-2022 走看看