简体   繁体   中英

Can I console.debug() and make Chrome Dev-tools breakpoint there?

Can I manually set breakpoints from my code(like by writing console.debug at that point).

Debugging problems with cache, it's important to breakpoint there the first time I load it. If I have to add a breakpoint then reload, I can't test caching(problems with functions not defined on first-load, but working subsequently).

See google documentation . Just write debugger in your code, and Chrome will pause execution there.

Manual breakpoints are individual breakpoints that you set on a specific line of code. You can set these via the Chrome DevTools GUI, or by inserting the debugger keyword in your code.

You can override console.debug and set debugger there, so we can change it to below

var debugCopy = console.debug.bind(console)
console.debug = function(){
  debugger;
  return debugCopy.apply(console,arguments)
}

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