引用:
Using the new code snippets feature in google chrome
我正在 google chrome 中使用代码片段,所以说我有一个片段文件。 check_consistency.js
是否有一个 API 或全局对象,我们可以通过它直接从命令行运行代码片段,例如:
window.runSnippet('check_consistency.js')
或者可以直接调用代码片段中定义的方法。
最佳答案
工作流程提示 1
我也希望看到添加此功能。同时,也许尝试打开Sources
,您可以在其中(如您所知)选择一个片段并右键单击它来运行它。您可能知道也可能不知道您可以在此页面上点击 Esc
以便在显示代码段的同时显示控制台:
工作流程提示 2
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/