chrome浏览器console拓展用法

chrome 浏览器console打印

使用CSS美化输出信息

  1. console.log("%cThis will be formatted with large, blue text", "color: blue; font-size: x-large");

    比较类似的数据对象

    使用table()方法查看结构化数据并比较数据对象。

    table()方法提供了一种简单的方法来查看包含类似数据的对象和数组。当调用时,它将获取到的对象属性创建为标题。每一行数据来自每个索引下的属性值。

    基本示例: 记录对象的数组

    在它最基本的形式中,你需要的是一个具有相同属性的对象数组。 table() 命令将完整剩下的工作:

    console.table([{a:1, b:2, c:3}, {a:"foo", b:false, c:undefined}]);
    console.table([[1,2,3], [2,3,4]]);

  2. 计数语句执行

    使用count()方法记录同一字符串输出的次数。当在同一行上给count()赋予同一字符串时,其输出的数字就加1。

    使用count()的示例代码(有一些动态内容哦):

    function login(user) {
        console.count("Login called for user " + user);
    }
    
    users = [ // by last name since we have too many Pauls.
        'Irish',
        'Bakaus',
        'Kinlan'
    ];
    
    users.forEach(function(element, index, array) {
        login(element);
    });
    
    login(users[0]);
    找了几个常用的复制到博客备用 原地址:http://www.css88.com/doc/chrome-devtools/

原文地址:https://www.cnblogs.com/MartinLee/p/7622546.html