有一些功能,可以做很长时间的工作,并提供回调.
someFunc: function(argument, callback, context) {
// do something long
// call callback function
callback(context);
}
Run Code Online (Sandbox Code Playgroud)
在应用程序中我使用此功能
someFunc('bla-bla', function (context) {
// do something with this scope
context.anotherFunc();
}, this);
Run Code Online (Sandbox Code Playgroud)
如何在不传递context参数的情况下实现回调函数?
需要这样的:
someFunc('bla-bla', function () {
// do something with this scope
this.anotherFunc();
}, this);
Run Code Online (Sandbox Code Playgroud)