// テキストファイル読み込み loadText( file // File object ) { let reader = new FileReader(); // fileを読み込み reader.readAsText(file); // UTF-8として読み込み reader.onload = function (evt) { this.text = evt.target.result; // ファイル内のテキスト }.bind(this); } // 画像読み込みと画像の幅・高さ取得 loadImage( file // File object ) { let reader = new FileReader(); // fileを読み込み reader.readAsDataURL(file); reader.onload = function (evt) { // src属性にURLをセットして、画像として再度読み込み this.ImgEle.src = evt.target.result; this.ImgEle.onload = function (evt) { // 画像としての読み込み完了後に幅と高さが取れる this.ImgWidthOrg = parseInt(evt.target.naturalWidth); // 画像のオリジナル幅 this.ImgHeightOrg = parseInt(evt.target.naturalHeight); // 画像のオリジナル高さ }.bind(this); }.bind(this); }