_onChunkComplete
メソッド内のthis
メソッドは、XHRリクエストです。どちらが理にかなっている。それを実際のUploader
オブジェクトにする方法はありますか?XmlHttpRequest onload `this`プロパティ
function Uploader(file, options) {
// ... code here ....
this.upload_request = new XMLHttpRequest();
this.upload_request.onload = this._onChunkComplete;
}
Uploader.prototype = {
// ... code here ...
_onChunkComplete: function() {
if (this.range_end === this.file_size) {
console.log('done');
return;
}
this.range_start = this.range_end;
this.range_end = this.range_start + this.chunk_size;
if (!this.is_paused) {
this._upload();
}
}
// ... mode code here...
};
var test = new Uploader(formFile, {});
test.start();
どのように私はこれについて知らなかった... 私は '.bind(本)でした'と、それは完璧に動作します。ありがとうございました。 – Charlie