Getting 'Uncaught Error: Script error' for a declared dependency when using r.js

百般思念 提交于 2019-12-05 08:34:30

The problem is that common is not guaranteed to be loaded first. So when RequireJS gets to require('library') then the configuration may or may not have been set. When you call require(['a', 'b', 'c'], function () {}) RequireJS is free to load c first, or b first, or a first. The order is not set. The only guarantee is that all the modules will be loaded before the callback is called.

So change main-page1.js so that it contains:

require(['common'], function () {
    require(['app/app1','app/app1jq']);
});

This will ensure that common is loaded before any of the code that depends on your configuration.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!