<分区>
在应用程序中:
var bootstrap = new Bootstrap();
bootstrap.init( this, this.onBootstrapComplete );
在 Bootstrap 中:
this.init = function( app, completeHandler ){
_app = app;
_completeHandler = completeHandler;
...
}
...
var _allReady = function(){
_completeHandler( _app );
}
返回应用程序:
this.onBootstrapComplete = function( app )
{
app.something();
app.someValue = ...
}
我想在 onBootstrapComplete 中获取 this 上下文。 它有效,但看起来不正确:)
如果我想直接从 App 调用 onBootstrapComplete,我将不得不调用它 this.onBootstrapComplete( this )。
我该怎么做才能让我的 onBootstrapComplete 看起来像这样:
this.onBootstrapComplete = function()
{
this.something();
this.someValue = ...
}