为什么requirejs尝试加载.map? [英] Why is requirejs trying to load .map?

查看:386
本文介绍了为什么requirejs尝试加载.map?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从CDN(具体来说是CDNJS)加载脚本,在requirejs中,您必须像这样保留扩展名:

I am trying to load scripts from a CDN (cdnjs to be specific), and in requirejs you have to leave the extension off like so:

require.config({
    baseUrl: '/static/js/',
    paths: {
        underscore: ['//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.1/underscore-min']
    },
    shim: {
        'underscore': {
            exports: '_'
        }
    }
});

但是,当我这样做时,浏览器尝试加载下划线-分钟。地图而不是 underscore-min.js

But when I do this, the browser tries to load underscore-min.map and not underscore-min.js.

如何解决此问题,还有 .map 是什么?

How do I fix this, and also what is a .map?

推荐答案

.map 文件是浏览器中 sourceMap 支持所必需的。这是从CDN加载的文件的最后一行:

.map files are needed for sourceMap support in the browser. This is the last line from the file you load from the CDN:

 //# sourceMappingURL=underscore-min.map

此行使您的浏览器加载 .map 文件。

This line makes your browser to load the .map file.

这篇关于为什么requirejs尝试加载.map?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆