gpt4 book ai didi

javascript - dojo:qwest.js 的 multipleDefine 错误

转载 作者:行者123 更新时间:2023-12-03 09:15:19 40 4
gpt4 key购买 nike

我尝试使用 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`])

最佳答案

我真的不知道为什么会出现该错误,但您可以通过让 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>

关于javascript - dojo:qwest.js 的 multipleDefine 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31975069/

40 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com