loading multiple modules using requireJS in latest firefox 21.0 fails

你说的曾经没有我的故事 提交于 2019-12-08 08:42:27

As mentioned in the comments, the shim configuration is for Javascript files that do not support AMD module definitions and is used to import for example javascript libraries that add some variable to the window scope (like jQuery). Read more about shim here.

In your case, all your modules are AMD modules (they are all defined using define), so shim is not necessary. Instead you can just use the paths configuration to create aliases for your modules. Also moving your require.config out of the modules and into where your require call happens is recommendable.

So, remove the require.config from your purchase.js -file, then add the following to the beginning of your app.js -file

require.config({
  // with the paths -config, you create aliases for you modules
  // basically you tell require that this file contains definition for module x
  paths: {
    'purchase': 'path/to/purchase', // no .js file ending in the path
    'credit': 'path/to/credit',
    'product': 'path/to/product'
  }
});

You can read more about require.config here.

Now you have configured RequireJS so, that it knows where the modules purchase, credit and product are located and that it will load them. After this they can be referenced with their respective aliases when declaring RequireJS dependencies.

Hope this helps!

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