wenbobowen 4 years ago
parent
commit
3237e60654
1 changed files with 4 additions and 3 deletions
  1. 4 3
      src/components/input/normalArea.vue

+ 4 - 3
src/components/input/normalArea.vue

@@ -147,11 +147,12 @@ export default {
     },
     uploadImg(imgData) {
       var bytes = window.atob(imgData.split(',')[1]);
-      var array = [];
+      var ab = new ArrayBuffer(bytes.length);
+      var ia = new Uint8Array(ab);
       for(var i = 0; i < bytes.length; i++){
-          array.push(bytes.charCodeAt(i));
+          ia[i] = bytes.charCodeAt(i); //这里有点疑惑,ia是怎么改变ab的?注:①
       }
-      var blob = new Blob([new Uint8Array(array)], {type: 'image/jpeg'});
+      var blob = new Blob([ab], {type: 'image/jpeg'});
       var fd = new FormData();
       fd.append('file', blob);
       fd.append('innerPublic',true);