window 系统里 chrome 浏览器一些实用的调试技巧

Posted 凯小默

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了window 系统里 chrome 浏览器一些实用的调试技巧相关的知识,希望对你有一定的参考价值。

说明

某一天,我突然发现 chrome 浏览器竟是熟悉的陌生人,感觉好多操作都不知道,于是,我看了一些大佬写的笔记,自己把不会的一些整理了一下,记录起来,忘记的时候偶尔来看一看。

1、开发者工具里 Run Command

打开 Chrome 开发者工具,然后使用快捷键 Ctrl + Shift + P 打开命令菜单:

1.1 切换 chrome 主题

输入下面命令可以进行主题切换

  • Switch to dark theme
  • Switch to light theme

也可以输入 theme ,下面就会出现主题的切换,比如你现在是 light 主题,就会给你 dark 主题的切换选择


选了这之后,开发者工具就变成了 dark 主题

1.2 屏幕截图

  • Capture full size screenshot:用于截取网页上所有内容的屏幕快照,包括可视窗口中未出现的所有内容
  • Capture node screenshot:用于精确捕获 DOM 元素的内容

比如:我选择第一个命令 Capture full size screenshot


就会下载下来一张图片:可以看到这张图片,出现了页面未出现的所有内容

我们先选中这个 a 标签:


在使用第二个命令:

我们可以看到下载下来就是 a 标签这个部分的。

2、开发者工具里 Network

2.1 重新发送XHR请求

  • 打开网络面板
  • 点击 Fetch/XHR 按钮
  • 选择重新发送的 XHR 请求
  • 重发 Replay XHR

2.2 在控制台用 fetch 快速发起请求

  • 选择重新发送的 XHR 请求
  • 右键选择 copy 里的 Copy as fetch
  • 粘贴到控制台
  • 可以自己修改参数,回车执行

粘贴 Ctrl + v 到控制台执行:

你就发现调用了:

2.3 复制图片的Data URI

找到图片的 preview 然后右击选择 Copy image as data URI

下面链接就可以直接在浏览器上访问

data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB3aWR0aD0iMTc2cHgiIGhlaWdodD0iMTcycHgiIHZpZXdCb3g9IjAgMCAxNzYgMTcyIiB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3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geGxpbms6aHJlZj0iI3BhdGgtNCI+PC91c2U+CiAgICAgICAgICAgIDwvZz4KICAgICAgICA8L2c+CiAgICA8L2c+Cjwvc3ZnPg==

2.4 页面不同時期的加载截图

选择 Capture Screenshots 获得页面加载的截图。

3、开发者工具里 Source

打开 Chrome 开发者工具,然后使用快捷键 Ctrl + P 打开文件:

3.1 快速切换文件

比如我们打开上面的 normalize.css 文件

3.2 在源代码中搜索

按住 Ctrl + Shift + f 进行搜索,这里不要把光标聚焦到源文件里面,不然出不来。

比:如搜索 mark 字段

3.3 源代码里跳转行数

ctrl + g,输入行数跳转

比如在上面的文件里跳转到第 5 行

3.4 通过 workspaces 实现编辑器功能

选择 Add folder to workspace,或者只是把整个工程文件夹拖放入Developer Tool,然后同意。就可以在开发者工具里编辑文件保存了。

3.5 添加条件断点

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      const blogs = [
        
          name: "kaimo666",
          value: 666,
        ,
        
          name: "kaimo777",
          value: 777,
        ,
        
          name: "kaimo888",
          value: 888,
        ,
      ];

      blogs.forEach((v) => 
        console.log(v.name, v.value);
      );
    </script>
  </body>
</html>

我们在 27 行打个断点,重新执行这段代码的时候,会停三下

我们在 27 行,右击选着编辑断点

输入条件: v.name === "kaimo888",然后失焦就行


重新执行这段代码的时候,只有满足条件的才会停

4、开发者工具里 Console

4.1 复制控制台的变量

复制函数不是由 ECMAScript 定义的,而是由 Chrome 提供的。

copy(location)

4.2 用表格的形式输出对象数组

Chrome 提供了一个表格函数 table,可以将对象数组制成表格。

let kaimoArr = [
	
		name: "kaimo666",
		value: 666
	,
		name: "kaimo777",
		value: 777
	,
		name: "kaimo888",
		value: 888
	,
];
table(kaimoArr)

4.3 控制台里 $ 相关的简写命令

需要注意的是:这个 $ 跟 jQuery 的不是一回事,如果页面有引入 jQuery,那么这个 $ 就表示 jQuery。

  • $()document.querySelector() 的简写,返回第一个和css选择器匹配的元素。
  • $$()document.querySelectorAll() 的简写,返回一个和css选择器匹配的元素数组。
  • $0-$4:依次返回五个最近你在元素面板选择过的DOM元素的历史记录,$0 是最新的记录,以此类推。
  • $_:引用上一次操作的结果,不用每次都复制一遍

'kaimo'.split('')
$_

5、开发者工具里 Elements

5.1 切换样式颜色格式

比如:下面的颜色显示格式是 rgb 的,我们可以按住 shift 点击颜色块进行切换。


切换之后

CSS颜色设置(6种方法):

5.2 存储 DOM 元素到全局临时变量中

比如我要存储 ReactApp 这个 dom 元素,我们可以右键这个元素,找到最下那个 Store as global variable


选择之后就会出现一个变量,供你使用,比如这里的 temp1 就是该 dom 元素:

5.3 一键展开 DOM 下面的所有元素

我们普通展开时只会展开它的子节点,如果我们想全部展开,可以按住 alt 在点击展开即可。


全部展开效果:

拓展阅读

以上是关于window 系统里 chrome 浏览器一些实用的调试技巧的主要内容,如果未能解决你的问题,请参考以下文章

Chrome实用小插件推荐

Chrome里必备的实用插件

Chrome 实用调试技巧

实用且堪称神器的Chrome插件推荐

Chrome浏览器中比较实用的一些插件(油猴文字复制广告拦截视频倍速文献下载)

Chrome浏览器中比较实用的一些插件(文字复制广告拦截视频倍速文献下载)