我的图书馆使用kriskowal/Q 承诺库现在我正在尝试加载(使用 requirejs)使用我的库的应用程序,因此我将所有路径和垫片以及我的requirejs.config
部分如下所示:
requirejs.config({
baseUrl: './',
catchError: false,
paths: {
beril: '../engine/build/src/bundle',
lodash: 'bower_components/lodash/lodash',
three: 'bower_components/three.js/build/three',
q: 'bower_components/q/q',
},
shim: {
lodash: {
exports: '_'
},
three: {
exports: 'THREE'
},
q: {
exports: 'Q'
},
beril: {
deps: ['lodash', 'three', 'q'],
exports: 'beril'
},
}
});
之后我假设变量 THREE、_ 和 Q 在全局空间中定义。
现在我正在使用这个简单的行加载并运行应用程序:
require(['beril', 'js/stepbystep/' + $stateParams.page + '/app'], (beril, app) => app());
但后来我收到错误:ReferenceError: Q is not defined
即使我可以在 Chrome 的网络检查器中看到 Q 库已加载。
还定义了所有其余依赖项(三个和_)。似乎 requirejs 的 shim 不适用于这个库。可能是或者我错过了什么?
那么我做错了什么以及我应该如何处理这种情况?