将图片转为base64,这样就不用找地方保存图片了,有时根本没有地方保存图片

在平台中发现根本没有地方保存图片,相对路径的方法用不了,所以用了网络地址,但是现实中不能这样做,怎么办呢?

将图片转换为Base64编码,可以让你很方便地在没有上传文件的条件下将图片插入其它的网页、编辑器中。

var upslice='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAYAAADhAJiYAAAC8UlEQVRYR+2WT2jUQBTGvzdZi3/AoojgRRFBrbRqBcX6Dw8iCt1N9lA2EdSjIIgVPIggFC8qgrSg4FEs7aZUbJO2Fr2IghU9WKRalOJFqaAX0WKF3c08iXR30+12k91UENycMpn3vvfLN28mIfxjF4XhcQz1CjP2E9E9JdnfHkYrm1sxkGNo7WA+m4NgblV67I6wUBUBObp2CeDLhcUZdCJi9neGgSobyDHU02Dcmq8og5sjpj1UKVRZQBlDM4i526+YILGHkn3P/eKKzQcGSie0w4L4YcAiUjhooF5rPGB8LiwQECeiOyWJl15xJjwlxm4ANQC+MvCBgCaP8pRg3kym/bkcKF8gTsQ3SpJjM4VntOmUiIgBmXEmAbga08KpWS6V1HUA5zwAk2Ka68i2p4JClQTi4/HVMi3fAVjhefO7StI6yce0XVLyi+xzoaRqqWv4R8ZQnxDjgCd+XGxqbKC2NhkEal4gjkaXymXC7YF1+UOLB4VpR91xRo/FCGTlgMA7yLRH3bGTUEdB2J6dY2AkYlp7QwE5uvoawFaP6LOIae3LjjMJ7SgRP8gBkayn5MBbd8wtLUukknLv1+dfBkPCtJr9oIo6NMd2xpjosbYRwEGA/kAZ0VWSxXsAKwuXuxTUHCCZUPuYoHmSPopFv7ZQ56OfXqFSDuVcTWgbJPEbAIvzUNShJPtb54OaBeToqrtDbniCvwniOkraXwoF0kbsiGAaLrZk3ljWY40S9Kog/4JiWteKQRUCuTDZbZsSwqmn7sGJYolBHMrmpXXtoAA/DuLSLCBuaamVkdRtZl6jKHSGuiz3/Cl6lQPkCrgnPZG8SEwTQtacp97e774O+e2AcnuoHD3PbqwkDSjXoa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z5PAJHYoJ542K1oY7E/eQqvHUJyOpDBFAwXHNyF2sIdH/xRlummo9pFiYEoCyvRU8KLhdq44A/eHFGdPsTAlA/kCdaZ0iEDtzPxxSHXDU7korsRNXVSVBElloCiz/gLxoFY0fSIIBwAAAABJRU5ErkJggg==';
var pingheng='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAYAAADhAJiYAAAAaklEQVRYR+3UsQkAIRBEUa3AgqzfgqxAY9ngIxis8C8dTobnYC3JvpqsT7EQ3YhCCpEA5W5IIRKg3A0pRAKUxw2Nueinp3lvRwcLBd3/hJ4O5P4wH0YyU0ghEqDcDSlEApS7IYVIgPJ0G9rrsQwluvrengAAAABJRU5ErkJggg==';
  for(let j in sell_theardObj){
		 let date_status=sell_theardObj.dataStatus == "上升"?upslice:(sell_theardObj.dataStatus == "下降"?downslice:pingheng);
         let tian_status=sell_theardObj.tianStatus == "上升"?upslice:(sell_theardObj.tianStatus == "下降"?downslice:pingheng);
		
    }

效果图

将图片转为base64,这样就不用找地方保存图片了,有时根本没有地方保存图片_第1张图片

在线图片转base64的网站分享给大家

图片转base64

你可能感兴趣的:(JS)