Chrome DevTools提供了哪些Command Line API?

Chrome的 DevTools能夠說是最強大的瀏覽器開發調試工具了,它的Console模塊又是最高頻使用的模塊之一,Console模塊提供了不少Command Line API方便咱們的開發調試。例如:javascript

須要注意的是上例API區別於consoleAPIhtml

Command Line API僅能在Chrome DevTools Console中使用。若是嘗試在腳本中調用它們,它們將沒法工做。java


那有沒有什麼辦法知道Chrome目前提供了哪些Command Line API呢。web

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script> var keyList = Reflect.ownKeys(window); </script>
  <script> </script>
</body>

</html>
複製代碼
  • 使用Chrome打開該HTML文件。
  • 而後在DevTools的Console中執行
var keyList2 = Reflect.ownKeys(window);
keyList2.filter(key=>!keyList.includes(key));
複製代碼

  • 能夠知道在Chrome 80版本中提供瞭如下27個Command Line API
["dir", "dirxml", "profile", "profileEnd", "clear", "table", "keys", "values", "debug", "undebug", "monitor", "unmonitor", "inspect", "copy", "queryObjects", "$_", "$0", "$1", "$2", "$3", "$4", "getEventListeners", "monitorEvents", "unmonitorEvents", "$", "$$", "$x"]
複製代碼
相關文章
相關標籤/搜索