Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有什么方法可以调试您从 firefox 开发人员控制台终端插入的代码?即我插入
document.onkeydown = function(event) { // check keys pressed and perform some logic }
如果我知道从开发者控制台输入的 javascript 去了哪里(它在哪个 .js 文件中),我可以调试它,但我无法弄清楚。
调试器;声明正是我所需要的。
document.onkeydown= function(event){ debugger; //function logic here }
然后从下图中你可以看到你可以在调试器中设置你需要的断点。
在 chrome 调试控制台中,键入:
document.onkeydown = function(event) { console.log(event) }
返回值将是一个函数,如下所示:
双击该功能,VM.js将打开一个选项卡。这包含 VM 为该函数生成的代码。你可以在那里设置断点。
VM.js