• <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 设置图像源

        时间:2023-10-01

            • <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 设置图像源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:使用javascript将二进制数据转换为base64 下一篇:JS - 从base64代码中获取图片的宽高

                  相关文章

                  1. <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>