javascript - Chrome 开发者工具 : What is Snippets Support?

标签 javascript google-chrome-devtools web-inspector

从版本 19 开始,Chrome 的 Web Inspector 具有一项称为“片段支持”的实验性功能。激活方法如下:

  1. 打开 chrome:flags,启用“开发者工具实验”,重新启动。

  2. 打开 Web Inspector(开发者工具),点击右下角的设置齿轮图标,启用“片段支持”,重启。

    enable snippets support

  3. 打开“脚本”面板,单击左侧的“导航树”图标,然后找到一个空的“代码段”选项卡。

    snippets tab

我的问题是:我可以用它做什么?我如何用代码片段填充它?

最佳答案

简而言之,snippets 是一个多行控制台,一个迭代的 JS 开发工作流程,以及一个用于常见调试助手的持久存储。

developers.google.com/chrome-developer-tools/docs/authoring-development-workflow#snippets

Some of the use-cases Snippets can help with are:

  • Bookmarklets - all of your bookmarklets could be stored as snippets, especially those you may wish to edit.
  • Utilities - debugging helpers for interacting with the current page can be stored and debugged. A community-curated list of such utilities is available.
  • Debugging - Snippets offer a multi-line console with syntax-highlighting and persistance, making it convenience for debugging code that is more than a one-liner.
  • Monkey-patching code - code you wish to patch at runtime can be done through Snippets, although many times you can just live-edit code in the Sources tab.

snippets screenshot

最后,我个人一直在收集一些您可能包含在您的武器库中的常见片段:github.com/paulirish/devtools-addons/wiki/Snippets


要快速运行代码片段,现在您可以这样做。 Ctrl-Shift-P 用于“命令面板”,然后退格,然后使用 !前缀,然后输入您要运行的代码段名称。

enter image description here

关于javascript - Chrome 开发者工具 : What is Snippets Support?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10470711/

相关文章:

javascript - 为 my nativescript-vue 应用程序自定义 ActionBar

google-chrome - 在网络选项卡下的检查器中没有看到来自网站的所有流量?

css - 从检查器(webkit、firebug 等)导出 CSS 更改

dom - 计算出的 DOM 节点/事件数与 Chrome 开发工具中的数字不一致

css - 是否可以使用 Chrome 开发者工具审核多个页面?

angular - 如何调试 Angular 2 源代码 typescript 文件

ios - 为什么 INSPECT ELEMENT 或 WEB INSPECTOR 或 developerExtrasEnabled (WkWebView) 在 iOS 中不起作用而在 OSX 中起作用

php - 如何使用ajax或jquery验证类型radio的答案

javascript - jQuery 将文本字段的值从不同的表单复制到另一个表单的文本字段

javascript - $(document).ready 在我将 jquery 库放在正文之前时不起作用