收藏
回答

wx.base64ToArrayBuffer总是报错thirdScriptErr

问题模块 框架类型 问题类型 API/组件名称 终端类型 微信版本 基础库版本
API和组件 小程序 Bug wx.base64ToArrayBuffer 工具 2.0.4 2.0.4

就这样两行代码就报错了,


这是后台接口返回的base64位的数据,既res.data.img的数据

"/9j/4AAQSkZJRgABAgAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0a\nHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIy\nMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCAAUADwDASIA\nAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQA\nAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3\nODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWm\np6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEA\nAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSEx\nBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElK\nU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3\nuLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwD0XUdT\nNlaahLG7zCO2MiBiRsZc4Dcg9cZ74/Osmx1LxJdxW00tzpHlyKsow0iuFIBxx8ufZu/tVzUIVeC/\nM0HmWy+avlR8MflIwoBH+z9TiuPt209dUsh4emmVzODNt3hRGOrMG+vGM9++KzsYVaklJa6ep2Wt\nazcWljbwWoa4vNQbyIEkVSMkfM5CHcFUZJ4OOBx1q3o0+tTPOurQ2aXCBWiktd6pKpzlSrjdkEA5\n6fOPcHkfFVon2vRry/t71bKBpI7sQhgxjZQM8DO3AIbnocDrxDob6emu3v8Awj/2v+wDEPvZCfaP\nl3BC/wA2Nh598Z420WNlVad2a1rrHi/Wrm9GnHSYILa7ltl+0JIrMV9cbhnBHp39KvyT6nYWUsk7\nq10ltvlCyjqq5YDJOBknHfH41xOsSeH7e7vpLZbyHXDI4jEUknnCUnhgw+Uhic8dVJxg4rrJX1Q+\nF28wSTakkaHht4L/AChgACQTyTx3wOc4ptHTiNYqSVvwJ9E8RapPd2KXwspbW6id/OgJBiwAfn7D\nkhe3J6+vSzTXUcmIrQSrj73mAfoa83006amo2H9kGRppNqXAkX5FjOd5fPRvu4KnHHY13MEc1shi\na+S2Kn7jKCD7gk9D/PNSYUqkmrMSK4+120kksabhvlG0sPmULg9feqO0SBAQQHhZyAx4K7sdfYY+\nlFFNDmtCH7TLiMF2KxkEKWOOPx49OKuy/LpqXYzvlLIV3HABznvntnkkcmiigzjszOjkMbhhg8EE\nHuCMEUCR1cOGO4DGTzxjGPpjiiimZdAZ2c5Y5Pr3P19ak+1Sf7BA6BkDbR6DOTiiigE2f//Z"

回答关注问题邀请回答
收藏

3 个回答

  • 小程序技术专员-SgLy
    小程序技术专员-SgLy
    2018-10-09

    你贴出来的 base64 格式不太对,可以用在线的工具解码试试,可能要你们后台自查一下啦

    2018-10-09
    赞同
    回复 6
    • Sammy Li
      Sammy Li
      2018-10-09

      没错,只是没有加 data:image/png;base64, 开头,在微信小程序还是显示不出来  

      2018-10-09
      回复
    • 小程序技术专员-SgLy
      小程序技术专员-SgLy
      2018-10-09回复Sammy Li

      不是开头的问题,你贴出来的 base64 确实有问题,没法解出图片。你可以用各种在线工具试一下

      2018-10-09
      回复
    • Sammy Li
      Sammy Li
      2018-10-09回复小程序技术专员-SgLy

      /9j/4AAQSkZJRgABAgAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0a

      HBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIy

      MjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCAAUADwDASIA

      AhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQA

      AAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3

      ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWm

      p6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEA

      AwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSEx

      BhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElK

      U1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3

      uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwDvZrq3

      trdpJokDxsXYg5dfmfOT1PAAz2zn0qgNY1S3jj1Jo4ksJQpMbys7RLlRubjkfMDgc8irF5b3b2V9

      EfJX7UWXcxwCwJ6Htz6/hWE001xpqaQqyxXBSOOWORGAQbgdzZ6Dkc+/ua3sZSbR097NrAHl6YbY

      XYfc0d0xKMuDnhSSpztxk4rPsNZ146zdW16dNljt7USP9k3HY5Pyhgx3A4BJGOOM4zmp9Q1ZNGsb

      mW7RJYYlDxo/O8nPRsHqT9736DnFbTLF9LsbaaQmO5nXzpmGzLSN8zkYAHBwMdxwDisnG9RanSpW

      pvQq6n4t1az1iyg/s63XTri5igmnkl8zfvxnagIK4G7rkcDp3vaz4kbRNMuNS2mVIQVjUk4kBYAA

      88EZHJ5wfpnlfGGq2FrqOn232nFza3sM84VThBydwIGMYKnA9a6ForLW/D011Bbm/sJFctGiEu4G

      eFU4O4EcDOcgH0NbWRk+ayKdr4q1q1u7Ua7b2dvHeuIlmsmbMUhUkK6NuDEkAZBGMcnFdPbXkqRe

      XCJJUQ7Q6wlgf1GPp/TFeX2Fjp2s6vpUGl6hf3kdnIskk93KWS2jQZEahgoG8jA542jsDXosFqJo

      hvSQlRgFd/Q8/wBw+v8AnqVZEpslvGb+0riLcdpRic4P8AOPT+Ee/vVL7XJheF3K24NjkHjGOw6Y

      x0/IUUVS2QPdl3U7aKNJJEQKVm2ADpgqG/nn/OKbqU7ERAAASxK7AdiTk4+pA/L3OSikug31GTOL

      OSF4442MkSyMGXjJBBH0OelPSdo9VijABWKUxoT1Ck4xn27UUUCINQnaS/lJVAVJTheoGRk+9JJJ

      GscB+zREtHkk7h0JHY+1FFHRB1Z//9k=


      用这个,这个是接口输出的数据,经过

      wx.base64ToArrayBuffer(data) 就报错了


      2018-10-09
      回复
    • 小程序技术专员-SgLy
      小程序技术专员-SgLy
      2018-10-09回复Sammy Li

      测试没有复现错误噢,测试用例:wechatide://minicode/I07iX2mU7m39

      2018-10-09
      回复
    • Sammy Li
      Sammy Li
      2018-10-09回复小程序技术专员-SgLy

      我知道问题点在哪里了,我把数据用

      JSON.stringify()转化为字符串,每一个换行会变成换行符/n,有没有方法可以删了所以的/n?



      2018-10-09
      回复
    查看更多(1)
  • Yolanda
    Yolanda
    2019-05-27

    请问楼主解决问题了吗,我也是这个状况,不定时的报错

    2019-05-27
    赞同
    回复
  • 半寸灰
    半寸灰
    2018-10-09

    data:image/png;base64,/9j/4AAQSkZJRgABAgAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0a\nHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIy\nMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCAAUADwDASIA\nAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQA\nAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3\nODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWm\np6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEA\nAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSEx\nBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElK\nU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3\nuLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwD0XUdT\nNlaahLG7zCO2MiBiRsZc4Dcg9cZ74/Osmx1LxJdxW00tzpHlyKsow0iuFIBxx8ufZu/tVzUIVeC/\nM0HmWy+avlR8MflIwoBH+z9TiuPt209dUsh4emmVzODNt3hRGOrMG+vGM9++KzsYVaklJa6ep2Wt\nazcWljbwWoa4vNQbyIEkVSMkfM5CHcFUZJ4OOBx1q3o0+tTPOurQ2aXCBWiktd6pKpzlSrjdkEA5\n6fOPcHkfFVon2vRry/t71bKBpI7sQhgxjZQM8DO3AIbnocDrxDob6emu3v8Awj/2v+wDEPvZCfaP\nl3BC/wA2Nh598Z420WNlVad2a1rrHi/Wrm9GnHSYILa7ltl+0JIrMV9cbhnBHp39KvyT6nYWUsk7\nq10ltvlCyjqq5YDJOBknHfH41xOsSeH7e7vpLZbyHXDI4jEUknnCUnhgw+Uhic8dVJxg4rrJX1Q+\nF28wSTakkaHht4L/AChgACQTyTx3wOc4ptHTiNYqSVvwJ9E8RapPd2KXwspbW6id/OgJBiwAfn7D\nkhe3J6+vSzTXUcmIrQSrj73mAfoa83006amo2H9kGRppNqXAkX5FjOd5fPRvu4KnHHY13MEc1shi\na+S2Kn7jKCD7gk9D/PNSYUqkmrMSK4+120kksabhvlG0sPmULg9feqO0SBAQQHhZyAx4K7sdfYY+\nlFFNDmtCH7TLiMF2KxkEKWOOPx49OKuy/LpqXYzvlLIV3HABznvntnkkcmiigzjszOjkMbhhg8EE\nHuCMEUCR1cOGO4DGTzxjGPpjiiimZdAZ2c5Y5Pr3P19ak+1Sf7BA6BkDbR6DOTiiigE2f//Z



    加上data:image/png;base64试试    png图片格式   自己改 哈

    2018-10-09
    赞同
    回复 1
    • Sammy Li
      Sammy Li
      2018-10-09

      还是那样的,5次里面有1次是报错的,我都不知道是什么情况,有的时候没问题,有的时候就报错

      2018-10-09
      1
      回复
登录 后发表内容