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

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

                  相关文档推荐

                  Fetch multiple links inside foreach loop(在 foreach 循环中获取多个链接)
                  Backbone Fetch Request is OPTIONS method(Backbone Fetch Request 是 OPTIONS 方法)
                  Fetch API leaks memory in Chrome(Fetch API 在 Chrome 中泄漏内存)
                  How can I download and save a file using the Fetch API? (Node.js)(如何使用 Fetch API 下载和保存文件?(Node.js))
                  Send blob data to node using fetch, multer, express(使用 fetch、multer、express 将 blob 数据发送到节点)
                  Sending a custom User-Agent string along with my headers (fetch)(发送自定义用户代理字符串以及我的标头(获取))

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