用chrome调试一个 javascript 页面,调试时出现报错,但出错位置并没有像通常那样显示文件名:行号,而是显示vm:数字,这样就不知道到底是哪一行代码出现了问题,后来查找资料,在一个英文问答网站找到了答案。 It is abbreviation of the phrase Virtual Machine. In the Chrome JavaScript engine (called V8) each script has its own script ID. Sometimes V8 has no information about the file name of a script, for example in the case of an eval. So devtools uses the text "VM" concatenated with the script ID as a title for these scripts. Some sites may fetch many pieces of JavaScript code via XHR and eval it. If a developer wants to see the actual script name for these scripts she can use sourceURL. DevTools parses and uses it for titles, mapping etc. 简单的说就是在某些chrome的V8引擎下,某些报错项目不会显示具体文件名:行号,而是会显示VM(虚拟机的缩写):数字(脚本ID)。例如eval函数。 在我的页面里,就是eval语句少了分割用的逗号导致出错,修复后VM报错消失。 |
|