简体   繁体   English

在 IntelliJ IDEA 中调试 JavaScript

[英]Debug JavaScript in IntelliJ IDEA

How can I debug JavaScript for my website in IntelliJ IDEA without changing my build configuration?如何在不更改构建配置的情况下在 IntelliJ IDEA 中为我的网站调试 JavaScript?

I am able to debug the JavaScript in Chrome Console but it does not work very well.我可以在 Chrome 控制台中调试 JavaScript,但效果不佳。


Answer.回答。 It is really easy:这真的很容易:

回答

Create a new JavaScript Debug Run configuration and specify the WAMP address you normally use to open your application in browser as URL there.创建一个新的JavaScript 调试运行配置并指定您通常用于在浏览器中打开应用程序的 WAMP 地址作为URL See https://www.jetbrains.com/help/webstorm/2017.2/debugging-javascript-in-chrome.html#d45520e154 and linked topics.请参阅https://www.jetbrains.com/help/webstorm/2017.2/debugging-javascript-in-chrome.html#d45520e154和链接的主题。 You might also need to configure URL mappings in your configuration - https://www.jetbrains.com/help/webstorm/2017.2/debugging-javascript-deployed-to-a-remote-server.html#d46122e202您可能还需要在配置中配置 URL 映射 - https://www.jetbrains.com/help/webstorm/2017.2/debugging-javascript-deployed-to-a-remote-server.html#d46122e202

First you need to add intellij plugin for chrom and install it on chrom, then on configuration debug you need to choose run with javascript.首先,您需要为 chrom 添加intellij插件并将其安装在 chrom 上,然后在配置调试时您需要选择使用 javascript 运行。 I can show you screenshot if you want如果你愿意,我可以给你看截图

It is worth noting that you should have linked separate .js files for debugging.值得注意的是,您应该链接单独的 .js 文件以进行调试。 I was trying to debug JavaScript code which was within an .html file but the breakpoints were never hit.我试图调试 .html 文件中的 JavaScript 代码,但从未命中断点。 I looked later under the resources in Chrome Inspector and found out that the lines were not synchronized between the files, because for the debugger the first line was the first JavaScript line, but for the html file it was the first line of the file (DOCTYPE)我后来查看了 Chrome Inspector 中的资源,发现文件之间的行没有同步,因为对于调试器,第一行是第一行 JavaScript 行,但对于 html 文件,它是文件的第一行(DOCTYPE )

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM