Hover over a Live Expression to highlight a DOM node
当一个 Live Expression 的执行结果为一个 DOM 节点时, 悬浮在 Live Expression 的结果之上来在视口中高亮该结果.
When a Live Expression evaluates to a DOM node, hover over the Live Expression result to highlight that node in the viewport.
图片 1. 悬浮在一个 Live Expression 的结果之上来在是口中高亮这个节点
Figure 1. Hovering over a Live Expression result to highlight the node in the viewport
存储 DOM 节点为全局变量
Store DOM nodes as global variables
为了存储一个 DOM 节点为全局变量, 在 Console 中执行一个表达式, 其执行结果为一个节点, 右击执行结果, 而后选择 Store as Global variable.
To store a DOM node as a global variable, run an expression in the Console that evaluates to a node, right-click the result, and then select Store as global variable.
图片 2. 在 Console 中 Store as global variable
Figure 2. Store as global variable in the Console
或者, 在 DOM 树中右击该节点, 而后选择 Store as global variable.
Or, right-click the node in the DOM Tree and select Store as global variable.
图片 3. 在 DOM树 中 Store as global variable
Figure 3. Store as global variable in the DOM Tree
Initiator 和 priority 信息如今存在 HAR 导入和导出中
Initiator and priority information now in HAR imports and exports
若是你想要和同事分享诊断网络的日志, 你能够将网络请求导出到一个 HAR 文件
If you'd like to diagnose network logs with colleagues, you can export the network requests to a HAR file.
图片 4. 导出网络请求到一个 HAR 文件中
Figure 4. Exporting network requests to a HAR file
要导入这个文件回到网络面板中, 只要拖拽和放下该文件(译者注: 必须在网络面板中)
To import the file back into the Network panel, just drag and drop it.
当你导出一个 HAR 文件的时候, DevTools 如今在 HAR 文件中包含 initiator 和 priority 信息. 当你导入一个 HAR 文件回到 DevTools的时候, initiator 和 Priority 列如今将被填充.
When you export a HAR file, DevTools now includes initiator and priority information in the HAR file. When you import HAR files back into DevTools, the Initiator and Priority columns are now populated.
The _priority field states what priority level the browser assigned to the resource. This maps to the Priority column in the Requests table, which is hidden by default.
图片 7. Priority 列
Figure 7. The Priority column
右击 Requests 表格的头部, 而后选择 Priority 来显示 Priority 列.
Right-click the header of the Requests table and select Priority to show the Priority column.
图片 8. 如何展现 Priority 列
Figure 8. How to show the Priority column
注意: _initiator 和 _priority 字段如下划线开头是由于 HAR 规范 说明自定义的字段必须如下划线开头.
Note: The _initiator and _priority fields begin with underscores because the HAR spec states that custom fields must begin with underscores.
从主菜单进入命令菜单
Access the Command Menu from the Main Menu
使用命令菜单来快速进入 DevTools 面板, 标签, 和特性.
Use the Command Menu for a fast way to access DevTools panels, tabs, and features.
图片 9. 命令菜单
Figure 9. The Command Menu
你如今能够从主菜单打开命令菜单. 点击主菜单 按钮, 而后选择 Run command.
You can now open the Command Menu from the Main Menu. Click the Main Menu
button and select Run command.
图片 10. 从主菜单打开命令菜单
Figure 10. Opening the Command Menu from the Main Menu
Enable the enterpictureinpicture, leavepictureinpicture, and resize checkboxes in the Event Listener Breakpoints pane to pause whenever one of these picture-in-picture events fires. DevTools pauses on the first line of the handler.
Figure 11. Picture-in-Picture events in the Event Listener Breakpoints pane
(惊喜提示) 在 Console 中执行 monitorEvents() 来监听一个元素的事件触发
(Bonus Tip) Run monitorEvents() in the Console to watch an element's events fire
注意: 该段介绍一个较不为人所知的特性, 可是其已经存在于 DevTools 中很长时间了.
Note: This section covers a lesser-known feature that has been in DevTools for a long time.
假设你想要在这个 button 被聚焦同时依次按下 R, E, D 的时候给它的周围添加一个红色的边框, 可是你不知道要监听什么事件. 使用 monitorEvents() 来在 Console 中打印关于该元素的全部事件.
Suppose you want to add a red border around a button after focusing it and pressing
R,
E,
D, but you don't know what events to add listeners to. Use monitorEvents() to log all of the element's events to the Console.
获取该节点的一个引用.
Get a reference to the node.
图片 12. 使用 Store as global variable 来获取该节点的一个引用
Figure 12. Using Store as global variable to get a reference to the node
将该节点做为第一个参数传递给 monitorEvents()
Pass the node as the first argument to monitorEvents().
图片 13. 传递该节点给 monitorEvents()
Figure 13. Passing the node to monitorEvents()
和该节点作交互. DevTools 在 Console 中打印关于该节点的全部事件.
Interact with the node. DevTools logs all of the node's events to the Console.
图片 14. Console 中的该节点的事件
Figure 14. The node's events in the Console
调用 unmonitorEvents() 来中止在 Console 中打印事件.
Call unmonitorEvents() to stop logging events to the Console.
To discuss the new features and changes in this post, or anything else related to DevTools:
File bug reports at Chromium Bugs.
Discuss features and changes on the Mailing List. Please don't use the mailing list for support questions. Use Stack Overflow, instead.
Get help on how to use DevTools on Stack Overflow. Please don't file bugs on Stack Overflow. Use Chromium Bugs, instead.
Tweet us at @ChromeDevTools.
File bugs on this doc in the Web Fundamentals repository.
Consider Canary
Consider Canary
若是你使用 Mac 或者是 Windows, 考虑使用 Chrome Canary 做为你的默认开发浏览器. Canary 可让你体验到最新的 DevTools 特性.(译者注: 译者已经将 Chrome Canary 做为默认浏览器好久了, 为 Web 稍做贡献)
If you're on Mac or Windows, consider using Chrome Canary as your default development browser. Canary gives you access to the latest DevTools features.
Note: Canary is released as soon as its built, without testing. This means that Canary breaks about once-a-month. It's usually fixed within a day. You can go back to using Chrome Stable while Canary is broken.