[英]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.