在 Ext JS 4 中加载外部脚本

Load external script within Ext JS 4

在 Ext JS 4 中,我需要加载 D3 API。我正在使用下面的代码

loadScript: function(callback, scope) {  console.log('5) loadScript called');      
  Ext.Loader.injectScriptElement('http://d3js.org/d3.v3.js', onLoad, onError);
     console.log('D3 script loaded ');
    },


    onError : function() {
  console.log('On Error');
 },
 onLoad : function() {
  console.log('On Load');
  d3.select('body').append('div').style('position', 'absolute').style('padding', '0 10px').style('background', 'red').style('opacity', 0);
 },

但是,在浏览器控制台中,我收到以下错误 -

未捕获的 ReferenceError:未定义 onLoad

有人可以帮我改正上面的代码吗?

谢谢。

使用 this.onLoadthis.onError,像这样:

Ext.Loader.injectScriptElement('http://d3js.org/d3.v3.js', this.onLoad, this.onError, this);

(你也可以传递作用域)