简体   繁体   English

如何使调试器可以访问已评估的javascript代码?

[英]How do I make eval'd javascript code accessible to the debugger?

I just spent a long time trying to figure out how to use source maps to get eval'd javascript code to show up in the debugger where I could put break points on it and stuff. 我花了很长时间试图弄清楚如何使用源映射来获取评估的javascript代码以显示在调试器中,在该调试器中可以在其中放置断点。 I kept seeing hints that it was possible, but most of what I read had to do with source mapping minified code or CoffeeScript, and generally it all seemed impossibly complicated. 我一直在暗示这是可能的,但是我读到的大部分内容都与源代码映射的最小化代码或CoffeeScript有关,并且一般而言,这似乎都不可能实现。 But then I stumbled on the answer, which was ridiculously easy, and I'll answer my own question below. 但是后来我偶然发现了答案,这很简单,我将在下面回答我自己的问题。

Just put this at the end of the eval block: 只需将其放在评估块的末尾即可:

//@ sourceURL=foo.js

In the Chrome sources panel, foo.js now shows up under '(no domain)'. 在Chrome来源面板中,foo.js现在显示在“(无域)”下。

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

相关问题 如何从以下代码中删除eval()…-Javascript - How do I remove eval() from the following code … - Javascript 如何返回eval(代码)并使用JavaScript获取对象? - How do I return eval(code) and get an object back with JavaScript? 如何使ruby变量可被javascript文件访问? - How do I make a ruby variable accessible to a javascript file? 如何将动态生成的代码导入 webworker 以便在调试器中访问 - How can I import dynamically generated code into webworker to be accessible in debugger 当已经在“常规”调试器语句处停止时,如何进入 eval('debugger') 模式? - how do I go into eval('debugger') mode when already stopped at 'regular' debugger statement? 如何使评估功能安全? - How do I make the eval function safe? 如何使这个JavaScript代码可移植? - How do I make this JavaScript code portable? 如何在firefox调试器中搜索javascript? - How do I search for javascript in the firefox debugger? 如何使用 webpacker 使 Rails 6 项目中的页面可以访问 javascript 函数? - How do I make javascript functions accessible to pages in a Rails 6 project using webpacker? 如何使Internet Explorer Javascript调试器也暂停捕获的异常? - How do I make the Internet Explorer Javascript debugger also pause on caught exceptions?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM