Dojo 1.9 build 'multipleDefine' error while loading locale

只谈情不闲聊 提交于 2019-12-05 04:39:52

Can you post your requires in run.js ? Did you require "dojo/_base/config" there ?

[ just noticed the same error because I forgot it ;) ]

from the docs:

It is important to note the distinction between dojoConfig and dojo/_base/config. dojoConfig is purely for input purposes—this is how we communicate configuration parameters to the loader and modules. During the bootstrap process, dojo/_base/config is populated from these parameters for later lookup by module code.

GibboK

I had a similar issue with error

multipleDefine

when trying to include greensock library to my dojo project.

The issue appears when another library outside dojo declared its own define function (in my case was TweenMax) as they clash with dojo loader.

A solution is to make sure dojo loader is called after your library or script which use a define function have loaded.

So dojo should be the latest in your script to load in the html head:

<head>
    <script src="yourLibrary.js"></script>
    <script src="dojo/dojo.js"></script>
</head>

This problem is also visible using jQuery UI and other libraries.

There is a note about this in the loader documentation (at the time of this response anyway).

multipleDefine
AMD define was called referencing a module that has already been defined. The most common cause of this problem is loading modules via elements in the HTML document. Use the loader; don't use elements. The second most common cause is passing explicit module identifiers to define; don't do this either.

https://dojotoolkit.org/reference-guide/1.10/loader/amd.html

Many libraries now implement UMD which will basically try to auto-detect the existence of an AMD loader. For example, Bootstrap - the popular front-end framework - implements UMD.

So the following example will work (note that bootstrap will load globally):

<script src="path/to/bootstrap.js"></script><!--UMD packaged library-->
<script src="path/to/dojo/dojo.js"></script><!--then dojo loader-->

but the second example below will not work, since the UMD code will detect the AMD loader and use that to register itself. This will trigger the multipleDefine error as per the documentation.

<script src="path/to/dojo/dojo.js"></script><!--dojo loader first-->
<script src="path/to/bootstrap.js"></script><!--then UMD library-->

If you want to load the library globally use the first example above and load it bofore the dojo loader. If you want to load the library as an AMD module, use the loader.

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