且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

RequireJS使用AMD模块随机加载错误的文件名

更新时间:2023-11-10 22:29:34

当您请求这样的文件时:

When you request your files like this:

<script src="/AnswersDev/Scripts/require.js" data-main="/AnswersDev/Scripts/main"></script>
<script type="text/javascript">
    require(['Views/add-report']);
</script>

可能是在main.js脚本之前调用了内联require(如果我理解正确的话,您的配置在哪里).

Chances are that the inline require is called before the main.js script (where is your config if I understand correctly).

因此,您都需要从main.js文件加载.您可以使用config deps选项加载某些文件.或者,您也可以将它们全部内联,但这会破坏目的.

So you all need to load from the main.js files. You can use the config deps option to load some files. Or you could also all include them inline, but that defeat the purpose.