Merge branch 'master' of gitee.com:_init_/hexo_blog

This commit is contained in:
结发受长生
2020-03-15 08:51:22 +08:00
2 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -33,4 +33,4 @@
"nunjucks": "^3.2.0",
"optimist": "^0.6.1"
}
}
}
@@ -26,11 +26,11 @@ fileInput.addEventListener('change', function() {
var file = fileInput.files[0];
var reader = new FileReader();
var fileBase64 = null;
reader.onload = function() {
reader.onload = function(e) {
fileBase64 = e.target.result; //base64编码
}
reader.readAsDataURL(file);
}
})
```
这里获取到的`fileBase64`就是文件的base64编码
如果这个文件是一个图片 , 我们当然可以借助它来实现所选图片的预览