Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
342 views
in Technique[技术] by (71.8m points)

javascript - 在Chrome控制台上调试JavaScript函数(debug javascript function on chrome console)

Two Questions about debugging in chrome console :

(有关在chrome控制台中进行调试的两个问题:)

  1. How can I debug function that I am writing directly in the chrome console on the fly ?

    (如何调试即时在chrome控制台中直接编写的功能?)

    for example

    (例如)

 function say(){ console.log("hello"); console.log("test"); } 

I want to set breakpoints,etc..

(我想设置断点,等等。)

And how can I do a tab in a console for indention?

(以及如何在控制台中创建用于缩进的选项卡?)

Thank you.

(谢谢。)

  ask by dudi du translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

1.Someone may have a better solution.(1.有人可能有更好的解决方案。) Try:(尝试:)

debugger;say()

in your console, and then press F11 twice, you will be navigated to a VMxxxx tab, you can add breakpoints there and it will be kept.

(在控制台中,然后按两次F11键,您将导航到VMxxxx选项卡,可以在其中添加断点并将其保留。)

ie next time you run say() in the console, the breakpoint will be triggered.

(即,下次您在控制台中运行say()时,将触发断点。)

2.I haven't figured out a way to do it either, but you may try Shift+Enter to open a new line and ident with spaces, or copy a "tab" from somewhere else (a text editor) and paste it in chrome.(2.我也没有想办法,但是您可以尝试使用Shift+Enter打开新行并用空格标识,或者从其他地方(文本编辑器)复制“标签”并将其粘贴到铬。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...