[英]How to chain dependencies in an AMD declared Dojo module?
我不明白在定义模块时如何链接加载程序调用,因为define需要返回,但是自身不返回任何东西,因此我不确定该怎么做。
define([
'require',
'https://code.jquery.com/jquery-3.3.1.min.js',
],
function (require) {
//Should I use a require or define...? I don't understand, none works
return define([
'https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.bundle.min.js'
],
function() {
const myModule = {...};
return myModule;
})
});
我必须执行上述操作的原因是因为我需要在加载引导程序之前先加载jquery,因为AMD加载程序是异步的,并且Bootstrap需要已经加载jquery。
您可以使用requirejs的配置选项。 不熟悉dojo
但是通常您会做的事情是这样的:
require.config({ paths: { 'jquery': 'pathTo/jquery.min', 'bootstrap': 'pathTo/bootstrap.min' }, shim: { 'bootstrap': { deps: ['jquery'] } } })
更多关于require config 在这里
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.