[英]Convert Image http get result to Base64 string in Javascript
I have a request to an url that retrieves an image, it's something like this: 我有一个检索图像的网址请求,就像这样:
this.$http.get(url, { }).success( (data) => {
console.log(data)
});
The result of console.log(data) is somethis like this console.log(data)的结果是这样的
PNG IHDR SZ sRGB gAMA a pHYs o d IDATx^ t ֵ= 3333339qb...
So, how can I convert this result to a base64 string ? 因此,如何将结果转换为base64字符串?
您可以使用btoa
方法:
console.log(window.btoa(data))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.