2015-10-01 101 views
2

Uncaught ReferenceError: dicomParser is not defined hr.onreadystatechange @ cornerstoneWADOImageLoader.js:4156未捕获ReferenceError:dicomParser未定义

我正在做我的应用程序与backbone,node.js和require.js。

CornerstoneWADOImageLoader失败,因为它没有找到dicomParser,但我已经定义了它。

要使用cornerstoneWADOImageLoader需要jQuery,基石和dicomParser。

有什么不对吗?

而且Uncaught cornerstone.enable(element);返回该错误

TypeError: element.appendChild is not a function

代码:

//boot.js 
require.config({ 
     paths: { 
     jquery:     '/js/lib/jquery', 
     jqueryui:    '/js/lib/jquery-ui', 
     'jquery.ui.widget' : '/js/lib/jquery.ui.widget', 
     underscore:    '/js/lib/underscore', 
     backbone:    '/js/lib/backbone', 
     text:     '/js/lib/text', 
     bootstrap:    '/js/lib/bootstrap.min', 
     require:    '/js/lib/require', 
     marionette:    '/js/lib/backbone.marionette.min', 
     'cornerstone':   '/js/lib/cornerstone/dist/cornerstone', 
     'dicomParser':   '/js/lib/dicomParser/dist/dicomParser', 
     'jpx':      '/js/lib/jpx.min', 
     'cornerstoneWADOImageLoader':'/js/lib/cornerstoneWADOImageLoader/dist/cornerstoneWADOImageLoader' 

}, 
shim: { 
    'bootstrap': ['jquery'], 
    'cornerstone':['jquery','dicomParser'], 
    'cornerstoneWADOImageLoader':['jquery','cornerstone','dicomParser','jpx'] 
} 
}, 

}); 
require(['jquery', 
    'underscore', 
    'app', 
    'bootstrap' 
], function ($, _, app) { 
    app.start(); 
}); 


///dicomView 

define([ 
    'jquery', 
    'underscore', 
    'backbone', 
    'text!templates/dicomViewTemplate.html', 
    'cornerstone', 
    'dicomParser', 
    'jpx', 
    'cornerstoneWADOImageLoader', 

], function ($, _, Backbone, dicomViewTemplate) { 

return Backbone.View.extend({ 

    render: function() { 
     this.$el.append(dicomViewTemplate); 


     var imageId = 'wadouri:dicom/55fc82d462eea6702a4c0a65' 
     var element = $('#dicomImage'); 
     cornerstone.enable(element); 
     cornerstone.loadImage(imageId).then(function(image) { 
      cornerstone.displayImage(element, image); 
     }); 

     return this; 
     } 
    }); 
}); 

回答

1

问题可能与dicomParser支持AMD,但基础不(还取决于它)。看看你是否可以使用AMD模块导入dicomParser w/o(也许通过shim配置)?如果这不起作用,请尝试从dicomParser中删除AMD位。

相关问题