Home >Web Front-end >JS Tutorial >11 chrome debugging tips that can improve efficiency
This article will share with you 11 advanced chrome debugging skills. Learn to directly increase the efficiency by 666%. I hope it will be helpful to my friends!
Chrome browser is the wife
of front-end children’s shoes, I believe you must be familiar with it. Adjust the page
, Write BUG
,Painting style
,Watch php movie
Without it, the whole world will not be good.
Do not believe? Let’s take a look at how powerful our wife
is....
with the backend When jointly debugging interfaces or troubleshooting online bugs, do you often hear them say this: Try making another request and let me see why something went wrong!
Resend the request, there is a ridiculously simple way.
SelectNetwork
ClickFetch/XHR
Select the request to resend
Right click and selectReplay XHR
modify the input parameters Restart, is there any shortcut?
Network
Fetch/XHR
Copy as fetch
fetch by hand. It’s really stupid to think about it...
complex object after calculation, and needs to be copied and sent to others ,what to do?
copy function and execute the
object as an input parameter
JSON.stringify(fetfishObj, null, 2) to print to the console, and then manually copy and paste. This efficiency is really low...
Elements panel, if you want to use
JS What should I do if I know some of its attributes, such as
width,
height,
position, etc.?
Elements
$0
is required to capture the content that exceeds one screen?
cmd shift p Execute
CommandCommand
Capture full size screenshot Press Enter
if Want to intercept some selected elements?
The answer is also very simple. In the third step, enterCapture node screenshot to get
opt key and click (the outermost element that needs to be expanded)
'fatfish'.split('').reverse().join('') // hsiftaf
You might do this
// 第1步 'fatfish'.split('') // ['f', 'a', 't', 'f', 'i', 's', 'h'] // 第2步 ['f', 'a', 't', 'f', 'i', 's', 'h'].reverse() // ['h', 's', 'i', 'f', 't', 'a', 'f'] // 第3步 ['h', 's', 'i', 'f', 't', 'a', 'f'].join('') // hsiftaf
更简单的方式
使用$_
引用上一次操作的结果,不用每次都复制一遍
// 第1步 'fatfish'.split('') // ['f', 'a', 't', 'f', 'i', 's', 'h'] // 第2步 $_.reverse() // ['h', 's', 'i', 'f', 't', 'a', 'f'] // 第3步 $_.join('') // hsiftaf
有的同学喜欢chrome的白色主题,有的喜欢黑色,我们可以使用快捷键迅速切换两个主题。
cmd + shift + p
执行Command
命令
输入Switch to dark theme
或者Switch to light theme
进行主题切换
$
"和"$$
"选择器在控制台使用document.querySelector
和document.querySelectorAll
选择当前页面的元素是最常见的需求了,不过着实有点太长了,咱们可以使用$
和$$
替代。
$i
直接在控制台安装npm包你遇到过这个场景吗?有时候想使用比如dayjs
或者lodash
的某个API
,但是又不想去官网查,如果可以在控制台直接试出来就好了。
Console Importer 就是这么一个插件,用来在控制台直接安装npm
包。
安装Console Importer
插件
$i('name')安装npm包
假设有下面这段代码,咱们希望食物名字是?
时才触发断点,可以怎么弄?
const foods = [ { name: '?', price: 10 }, { name: '?', price: 15 }, { name: '?', price: 20 }, ] foods.forEach((v) => { console.log(v.name, v.price) })
这在大量数据下,只想对符合条件时打断点条件将会非常方便。试想如果没有条件断点咱们是不是要点n次debugger?
The above is the detailed content of 11 chrome debugging tips that can improve efficiency. For more information, please follow other related articles on the PHP Chinese website!