在Chrome的控制檯中,您可以編寫相當不錯的東西。結帳this鏈接。我還做了一個截圖:如何用console.log省略文件/行號
正如你在截圖中看到過,文件名/行號(VM298:4
)是在合適的寫入。是否有可能刪除,因爲在我的情況下,這是一個很長的名稱,或多或少打破了我試圖在我的控制檯中的效果?
在Chrome的控制檯中,您可以編寫相當不錯的東西。結帳this鏈接。我還做了一個截圖:如何用console.log省略文件/行號
正如你在截圖中看到過,文件名/行號(VM298:4
)是在合適的寫入。是否有可能刪除,因爲在我的情況下,這是一個很長的名稱,或多或少打破了我試圖在我的控制檯中的效果?
這是非常簡單的做文件較短的名稱。您將需要使用setTimeout
有console.log.bind
:
setTimeout (console.log.bind (console, "This is a sentence."));
如果要應用CSS或其他文本,以它只是添加添加%c
或任何其他%
變量:
setTimeout (console.log.bind (console, "%cThis is a sentence.", "font-weight: bold;"));
var css = "text-decoration: underline;";
setTimeout (console.log.bind (console, "%cThis is a sentence.", css));
注意,此方法將始終放在日誌列表的末尾。例如:
console.log ("Log 1");
setTimeout (console.log.bind (console, "This is a sentence."));
console.log ("Log 2");
將顯示爲Log 1/Log 2/This is a sentence.
而不是Log 1/This is a sentence./Log 2
。
另一種選擇是給你的源腳本中使用sourceURL
//# sourceURL=new_file_name.js