• <tfoot id='DH5L3'></tfoot>
    <i id='DH5L3'><tr id='DH5L3'><dt id='DH5L3'><q id='DH5L3'><span id='DH5L3'><b id='DH5L3'><form id='DH5L3'><ins id='DH5L3'></ins><ul id='DH5L3'></ul><sub id='DH5L3'></sub></form><legend id='DH5L3'></legend><bdo id='DH5L3'><pre id='DH5L3'><center id='DH5L3'></center></pre></bdo></b><th id='DH5L3'></th></span></q></dt></tr></i><div id='DH5L3'><tfoot id='DH5L3'></tfoot><dl id='DH5L3'><fieldset id='DH5L3'></fieldset></dl></div>
          <bdo id='DH5L3'></bdo><ul id='DH5L3'></ul>

      1. <small id='DH5L3'></small><noframes id='DH5L3'>

        <legend id='DH5L3'><style id='DH5L3'><dir id='DH5L3'><q id='DH5L3'></q></dir></style></legend>
      2. 如何使用 base64 设置图像源

        How can I set Image source with base64(如何使用 base64 设置图像源)

            • <bdo id='BhnHw'></bdo><ul id='BhnHw'></ul>
              <legend id='BhnHw'><style id='BhnHw'><dir id='BhnHw'><q id='BhnHw'></q></dir></style></legend>
              <tfoot id='BhnHw'></tfoot>

              <small id='BhnHw'></small><noframes id='BhnHw'>

              1. <i id='BhnHw'><tr id='BhnHw'><dt id='BhnHw'><q id='BhnHw'><span id='BhnHw'><b id='BhnHw'><form id='BhnHw'><ins id='BhnHw'></ins><ul id='BhnHw'></ul><sub id='BhnHw'></sub></form><legend id='BhnHw'></legend><bdo id='BhnHw'><pre id='BhnHw'><center id='BhnHw'></center></pre></bdo></b><th id='BhnHw'></th></span></q></dt></tr></i><div id='BhnHw'><tfoot id='BhnHw'></tfoot><dl id='BhnHw'><fieldset id='BhnHw'></fieldset></dl></div>

                    <tbody id='BhnHw'></tbody>
                  本文介绍了如何使用 base64 设置图像源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想将图像源设置为 base64 源,但它不起作用:

                  I want to set the Image source to a base64 source but it does not work:

                  JSfiddle.net/NT9KB

                  <img id="img" src="" />
                  

                  JavaScript

                  document.getElementById("img").src = "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUA
                  AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
                  9TXL0Y4OHwAAAABJRU5ErkJggg=="
                  

                  推荐答案

                  尝试使用 setAttribute 代替:

                  document.getElementById('img')
                      .setAttribute(
                          'src', 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=='
                      );
                  

                  真正的答案:(并确保删除 base64 中的换行符.)

                  Real answer: (And make sure you remove the line-breaks in the base64.)

                  这篇关于如何使用 base64 设置图像源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  在开发JS过程中,会经常遇到两个小数相运算的情况,但是运算结果却与预期不同,调试一下发现计算结果竟然有那么长一串尾巴。如下图所示: 产生原因: JavaScript对小数运算会先转成二进制,运算完毕再转回十进制,过程中会有丢失,不过不是所有的小数间运算会
                  问题描述: 在javascript中引用js代码,然后导致反斜杠丢失,发现字符串中的所有\信息丢失。比如在js中引用input type=text onkeyup=value=value.replace(/[^\d]/g,) ,结果导致正则表达式中的\丢失。 问题原因: 该字符串含有\,javascript对字符串进行了转
                  Rails/Javascript: How to inject rails variables into (very) simple javascript(Rails/Javascript:如何将 rails 变量注入(非常)简单的 javascript)
                  CoffeeScript always returns in anonymous function(CoffeeScript 总是以匿名函数返回)
                  Ordinals in words javascript(javascript中的序数)
                  getFullYear returns year before on first day of year(getFullYear 在一年的第一天返回前一年)

                        <tbody id='jXKJ5'></tbody>
                    • <legend id='jXKJ5'><style id='jXKJ5'><dir id='jXKJ5'><q id='jXKJ5'></q></dir></style></legend>
                        <tfoot id='jXKJ5'></tfoot>

                        <small id='jXKJ5'></small><noframes id='jXKJ5'>

                        1. <i id='jXKJ5'><tr id='jXKJ5'><dt id='jXKJ5'><q id='jXKJ5'><span id='jXKJ5'><b id='jXKJ5'><form id='jXKJ5'><ins id='jXKJ5'></ins><ul id='jXKJ5'></ul><sub id='jXKJ5'></sub></form><legend id='jXKJ5'></legend><bdo id='jXKJ5'><pre id='jXKJ5'><center id='jXKJ5'></center></pre></bdo></b><th id='jXKJ5'></th></span></q></dt></tr></i><div id='jXKJ5'><tfoot id='jXKJ5'></tfoot><dl id='jXKJ5'><fieldset id='jXKJ5'></fieldset></dl></div>
                          • <bdo id='jXKJ5'></bdo><ul id='jXKJ5'></ul>