从版本 19 开始,Chrome 的 Web Inspector 具有一项称为“片段支持”的实验性功能。激活方法如下:
打开 chrome:flags,启用“开发者工具实验”,重新启动。
打开 Web Inspector(开发者工具),点击右下角的设置齿轮图标,启用“片段支持”,重启。
打开“脚本”面板,单击左侧的“导航树”图标,然后找到一个空的“代码段”选项卡。
我的问题是:我可以用它做什么?我如何用代码片段填充它?
最佳答案
简而言之,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.
最后,我个人一直在收集一些您可能包含在您的武器库中的常见片段:github.com/paulirish/devtools-addons/wiki/Snippets
要快速运行代码片段,现在您可以这样做。 Ctrl-Shift-P 用于“命令面板”,然后退格,然后使用 !前缀,然后输入您要运行的代码段名称。
关于javascript - Chrome 开发者工具 : What is Snippets Support?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10470711/