teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

1

誤りを訂正

2021/03/15 04:21

投稿

Lhankor_Mhy
Lhankor_Mhy

スコア37468

answer CHANGED
@@ -11,8 +11,8 @@
11
11
  const picture = await this.getBase64(file)
12
12
  const binary = window.atob(picture.split(',')[1]) // バイナリ ←必要なのはこれ?
13
13
  const arr = new TextEncoder().encode(binary) // typedArray
14
- const blb = new Blob(arr, { type: 'image/png' }) // blob ←必要なのはこれ?
14
+ const blb = new Blob([arr.buffer], { type: 'image/png' }) // blob ←必要なのはこれ?
15
- const picture2 = await this.getBase64(file) // dataURL に戻すと
15
+ const picture2 = await this.getBase64(blb) // dataURL に戻すと
16
16
  console.log(picture === picture2) // 一致する
17
17
  }
18
18
  ```