javascript - 使用(实验性)代码片段功能从 Google Chrome 控制台命令行运行代码片段?

标签 javascript google-chrome google-chrome-devtools javascript-debugger

引用:

Using the new code snippets feature in google chrome

我正在 google chrome 中使用代码片段,所以说我有一个片段文件。 check_consistency.js

是否有一个 API 或全局对象,我们可以通过它直接从命令行运行代码片段,例如:

  window.runSnippet('check_consistency.js')

或者可以直接调用代码片段中定义的方法。

最佳答案

工作流程提示 1

我也希望看到添加此功能。同时,也许尝试打开Sources,您可以在其中(如您所知)选择一个片段并右键单击它来运行它。您可能知道也可能不知道您可以在此页面上点击 Esc 以便在显示代码段的同时显示控制台:

工作流程提示 2

snippets documentation还提到

The ability to quickly locate a specific file can be essential to a developer's workflow. The DevTools allow you to search across all script, stylesheet and snippet files using the following shortcuts:

Ctrl + O (Windows, Linux)
Cmd + O (Mac OSX)

which will work regardless of the panel you are currently in.

...还有...

A keyboard shortcut is also available for easily executing a snippet - just select your snippet then use Ctrl/Cmd + Enter to run it. This replicates the behavior of the Run (>) button - currently in the Sources console, but which will be moving into the debugger control in the near future.

这意味着,在控制台中,您可以按 Ctrl/Cmd+O 快速选择代码片段,然后按 Cmd/Control+Enter 运行它。

关于javascript - 使用(实验性)代码片段功能从 Google Chrome 控制台命令行运行代码片段?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15579164/

相关文章:

php - 提交表单而不刷新页面

javascript - 从大型 JSON 中获取值以进行显示

javascript - 使用js创建异步循环

javascript - 尝试在 chrome 源选项卡中访问 "this.state"。我不确定

javascript - 在 Chrome 中添加 <select> 中的项目可以,在 IE 中则不行

javascript - 在 chrome 开发控制台中显示重复的 ID

javascript - 在客户端调试 Javascript

javascript - Firefox 和 Chrome 在 Javascript 中有什么区别?

javascript - 确定在 chrome 中调用了什么 javascript 函数

javascript - Google Chrome 开发者工具 - 无法设置断点