1. 程式人生 > >chrome瀏覽器console拓展用法

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/