我尝试使用dojo(ArcGIS)AMD加载程序加载qwest.js
,但收到multipleDefine
错误。
require([
// `../vendor/react/react.js`, // this works fine
`../vendor/qwest/qwest.min.js`, // this causes error
], (
// React,
qwest,
) => { ... })
起初我以为是因为我在dojo配置对象中将其添加为一个包,但这样做会引发完全相同的错误。
配置:
require({
async: true
, parseOnLoad: true
, packages: [{
name: `app`
, location: `${location.pathname}js`
, main: `main`
}]
}, [`app`])
答案 0 :(得分:1)
我真的不知道你为什么会收到这个错误,但你可以通过让qwest
认为应该使用commonjs而不是amd来解决它:
//for testing purpose
require({
packages: [{ name: 'pyrsmk', location: 'https://rawgit.com/pyrsmk'}]
});
//the trick is to let qwest think you use commonjs instead of amd
window.module = {};
require(['pyrsmk/qwest/master/build/qwest.min'], function(qwest) {
qwest = module.exports;
delete window.module;
console.log(qwest);
});
<script src="https://rawgit.com/dojo/dojo/1.10/dojo.js"></script>