Debug code调试代码
During a debugging session, you launch your application or file with the debugger attached to it. 在调试会话期间,启动应用程序或文件,并将调试器附加到该应用程序或文件。The debugger interferes the program execution and provides you with the information on what is happening under the hood. 调试器会干扰程序的执行,并向您提供有关引擎盖下正在发生的事情的信息。This facilitates the process of detecting and fixing bugs in your program.这有助于检测和修复程序中的错误。
With WebStorm, you can debug all kinds of applications written in JavaScript, TypeScript, or Dart: Node.js, React Native and Electron applications and, of course, client-side applications written using different frameworks. 使用WebStorm,您可以调试用JavaScript、TypeScript或Dart:Node.js编写的各种应用程序、React本机应用程序和Electron应用程序,当然还有使用不同框架编写的客户端应用程序。In addition to that, you can also debug unit tests and build scripts.除此之外,您还可以调试单元测试和构建脚本。
No matter what kind of code you are debugging, your experience with the WebStorm debugger is the same - you just put breakpoints and step through your actual source code even if you then compile it, WebStorm takes care of source maps.无论您调试的是哪种代码,您使用WebStorm调试器的体验都是一样的——您只需设置断点并逐步完成实际的源代码,即使您随后编译了它,WebStorm也会处理源代码映射。
During a debugging session, you can step through the application, examine it when suspended, resume program, evaluate expressions, change values on-the-fly, set watches, and more.在调试会话期间,您可以单步执行应用程序,在挂起时检查它,恢复程序,计算表达式,动态更改值,设置监视,等等。
In WebStorm, the JavaScript debugger works out of the box and in most cases its default settings are sufficient. 在WebStorm中,JavaScript调试器开箱即用,在大多数情况下,其默认设置就足够了。If necessary, you can configure the debugger as described in Configuring JavaScript debugger.如有必要,可以按照配置JavaScript调试器中的说明配置调试器。
WebStorm supports debugging client-side applications running on the built-in or an external web server. WebStorm支持调试在内置或外部web服务器上运行的客户端应用程序。Debugging of JavaScript code is available only in Google Chrome and other browsers of the Chrome family.JavaScript代码的调试仅在Google Chrome和Chrome系列的其他浏览器中可用。
This section describes the procedures that are common for various types of applications and frameworks. 本节介绍各种类型的应用程序和框架的常见过程。Also find more language- and technology-specific details:还可以查找更多特定于语言和技术的详细信息:
-
Running and debugging a React Native application运行和调试React本机应用程序 -
Running and debugging an Angular application运行和调试Angular应用程序 -
Running and debugging Dart command-line applications运行和调试Dart命令行应用程序 -
Running and debugging Dart web applications运行和调试Dart web应用程序
Useful debugger shortcuts有用的调试器快捷方式
Ctrl+F8 | |
| F9 |
Step over | F8 |
Step into | F7 |
Stop | Ctrl+F2 |
Ctrl+Shift+F8 | |
Shift+F9main method), or main 方法内部),或者Alt+Shift+F9 |