requirejs 没有正确加载对象
requirejs not loading the object properly
我正在使用 requirejs
配置 angularjs 项目依赖项
配置如下
"cornerstone-core":"emp/cornerstone.min",
"cornerstone-math":"emp/cornerstoneMath.min",
"hammer":"emp/hammer.min",
"properties":"emp/properties"
"clientParameters":"emp/clientParameters"
"cornerstone":"emp/cornerstone"
"cornerstoneMath":"emp/cornerstoneMath"
"cornerstoneTools":"emp/cornerstoneTools"
"cornerstoneWADOImageLoaderCodecs":"emp/cornerstoneWADOImageLoaderCodecs"
"cornerstoneWADOImageWebWorker":"emp/cornerstoneWADOImageWebWorker"
"myApp":"emp/myApp"
运行时依赖项是,
clientParameters : [ "properties" ],
cornerstoneMath : [ "properties", "clientParameters", "cornerstone-core", "cornerstone-math", "hammerjs" ]
cornerstone : [ "properties", "clientParameters", "cornerstone-core", "cornerstone-math", "hammerjs" ],
cornerstoneTools : [ "properties", "clientParameters", "cornerstone-core", "cornerstone-math", "hammerjs" ],
myApp : [ "properties", "clientParameters", "cornerstone", "cornerstoneMath", "cornerstone-core", "cornerstone-math", "hammerjs" ]
在cornerstone.js中,我按以下方式加载模块,
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define("cornerstone", [], factory); // error line
else if(typeof exports === 'object')
exports["cornerstone"] = factory();
else
root["cornerstone"] = factory();
})(this, function() {
return (function(modules) {
我收到以下错误,
myApp.js:2312 Uncaught(in promise) ReferenceError: cornerstone is not defined
在行 define("cornerstone", [], factory);
当我用 root["cornerstone"] = factory();
替换错误行时一切正常。
[编辑]
工厂方法是这个问题中使用的引导程序:
因为您正在使用模块,所以首先您必须导入 corerstone
。对于 AMD 模块,它看起来像:
define(["angular", "cornerstone"], function (angular, cornerstone) {
....
});
我正在使用 requirejs
配置如下
"cornerstone-core":"emp/cornerstone.min",
"cornerstone-math":"emp/cornerstoneMath.min",
"hammer":"emp/hammer.min",
"properties":"emp/properties"
"clientParameters":"emp/clientParameters"
"cornerstone":"emp/cornerstone"
"cornerstoneMath":"emp/cornerstoneMath"
"cornerstoneTools":"emp/cornerstoneTools"
"cornerstoneWADOImageLoaderCodecs":"emp/cornerstoneWADOImageLoaderCodecs"
"cornerstoneWADOImageWebWorker":"emp/cornerstoneWADOImageWebWorker"
"myApp":"emp/myApp"
运行时依赖项是,
clientParameters : [ "properties" ],
cornerstoneMath : [ "properties", "clientParameters", "cornerstone-core", "cornerstone-math", "hammerjs" ]
cornerstone : [ "properties", "clientParameters", "cornerstone-core", "cornerstone-math", "hammerjs" ],
cornerstoneTools : [ "properties", "clientParameters", "cornerstone-core", "cornerstone-math", "hammerjs" ],
myApp : [ "properties", "clientParameters", "cornerstone", "cornerstoneMath", "cornerstone-core", "cornerstone-math", "hammerjs" ]
在cornerstone.js中,我按以下方式加载模块,
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define("cornerstone", [], factory); // error line
else if(typeof exports === 'object')
exports["cornerstone"] = factory();
else
root["cornerstone"] = factory();
})(this, function() {
return (function(modules) {
我收到以下错误,
myApp.js:2312 Uncaught(in promise) ReferenceError: cornerstone is not defined
在行 define("cornerstone", [], factory);
当我用 root["cornerstone"] = factory();
替换错误行时一切正常。
[编辑]
工厂方法是这个问题中使用的引导程序:
因为您正在使用模块,所以首先您必须导入 corerstone
。对于 AMD 模块,它看起来像:
define(["angular", "cornerstone"], function (angular, cornerstone) {
....
});