问题描述
我有一个网页,是在Azure上运行的ASP.NET Web站点的一部分。它现在运行得很好了好一阵子。出于蓝,我突然有与浏览器尝试下载一个.MAP为Underscore.js一个问题。我做了一些阅读和JQuery的显然创造了.MAP文件作为调试工具为Javascript源文件(.js文件)。但是,如果我看脚本目录我的网站我看到这只是发生了一些jQuery的源文件,而不是一切,我不知道该模式是什么。
I have a web page that is part of a ASP.NET web site running on Azure. It's run fine for quite a while now. Out of the blue, I am suddenly having a problem with the browser trying to download a ".map" for Underscore.js. I did some reading and apparently JQuery creates ".map" files as debugging aids for Javascript source files (".js"). However, if I look at the Scripts directory for my web site I see that this only happens for some JQuery source files and not all and I am not sure what the pattern is.
然而,为什么会在浏览器试图加载一个Underscore.js地图文件,该文件是不是JQuery的一部分?另外,为什么会这样突然开始发生?我加Underscore.js到网页相当一段时间以前,从来没有过这个问题。
However, why would the browser be trying to load a "map" file for Underscore.js which is not part of JQuery? Also, why would this suddenly start happening? I added Underscore.js to the web page quite some time ago and never had this problem before.
确切的错误,当我看着在Chrome调试器控制台选项卡中我得到的是:
The exact error I get when I look in the Chrome Debugger Console tab is:
GET http://myazureapp.cloudapp.net/Scripts/underscore-min.map 404(未找到)脚本/下划线min.map:1
GET http://myazureapp.cloudapp.net/Scripts/underscore-min.map 404 (Not Found) Scripts/underscore-min.map:1
推荐答案
你所遇到的。这使您可以用缩小的JS文件时,在浏览器的开发者工具可读code调试。
What you're experiencing is source mapping. This allows you to debug with readable code in your browser's developer tools when working with minified JS files.
下划线的缩小的版本有此线在该文件的末尾
The minified version of Underscore has this line at the end of the file:
//# sourceMappingURL=underscore-min.map
您的浏览器的开发者工具将尝试下载下划线min.map
遇到此线时。
Your browser's developers tools will try to download underscore-min.map
when encountering this line.
如果你想摆脱错误的,或者:
If you want to get rid of the error, either:
- 删除从
下划线min.js该行
- 添加和的到您的项目。
- Remove that line from
underscore-min.js
- Add underscore-min.map and underscore.js to your project.
这篇关于失踪的Javascript" .MAP"加载ASP.NET网页文件时,对于Underscore.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!