热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

requirejs没有正确加载对象-requirejsnotloadingtheobjectproperly

Iamconfiguringangularjsprojectdependeciesusingrequirejs我正在使用requirejs配置angularjs项目依赖项follo

I am configuring angularjs project dependecies using requirejs

我正在使用requirejs配置angularjs项目依赖项

following are the configurations

以下是配置

"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"

Runtime dependencies are,

运行时依赖项是,

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" ]

In cornerstone.js I am loading the modules in a following way,

在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) {

I am getting the following error,

myApp.js:2312 Uncaught(in promise) ReferenceError: cornerstone is not defined

我收到以下错误,myApp.js:2312未捕获(在承诺中)ReferenceError:未定义基石

at line define("cornerstone", [], factory);
when I am replacing the error line with root["cornerstone"] = factory(); everything is working fine.

在线定义(“基石”,[],工厂);当我用root [“cornerstone”] = factory()替换错误行时一切都很好。

[EDIT]
factory method is bootstrapper used in this question: Trying to understand Webpack

[编辑]工厂方法是在这个问题中使用的bootstrapper:试图理解Webpack

1 个解决方案

#1


1  

Because you are using modules, first you have to import corerstone. With AMD modules it would look something like:

因为您使用的是模块,所以首先必须导入corerstone。使用AMD模块,它看起来像:

define(["angular", "cornerstone"], function (angular, cornerstone) {
    ....
});

推荐阅读
author-avatar
四季汤料_788
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有