简体   繁体   中英

Google Chrome Developer tools - Cannot set breakpoint

What have I done?
I'm running a ASP.net / Polymer website in VS2010 Development server.

It all used to run fine I could set a breakpoint in some JavaScript, run the site in Debug mode and it would break at the set location.

I obviously changed something though because now I can only set a breakpoint once the Javascript is loaded or by putting a debugger; statement in the code

Actually, I can set a breakpoint (or appear to) but it doesn't break at that location

Just me being stupid again
It turns out the problem was because I had added the folder containing the Javascript source to the workspace (by right clicking in the Sources pane)

Having done this the folder tree which used to appear under the localhost:nnnnn parent in the Sources pane no longer showed

Don't remember adding them but obviously I did
Removing the folders fixed it

I mainly put this answer here so that the next time I do the same thing and look it up on Stack Exchange I will find the answer

I have found the best way to add a breakpoint with Chrome is just adding this in the code:

debugger;

So long as the code is actually run and you have the javascript console open it will be caught.

But sometimes the I have found the dev tools get broken and require the entire browser to be restarted.

在开发人员工具的控制台中运行它。

location.reload(true);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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