这个错误通常在通过base64给images赋值时发生,setData()微信设置的一次最大传输长度为1M,所有如果编码后的base64字符串长度超过了1M就会报这个错误。

        如何解决?

        我们可以采取曲线救国的策略,在绑定数据的时候用两个变量,比如

<image class='img' src='{{imgSrc1 + imgSrc2}}' mode='widthFix'></image>

        然后后台js赋值的时候分两次赋值

let length = res.length;
_this.setData({
    imgSrc1: 'data:image/png;base64,' + res.substring(0, Math.ceil(length / 2))
});
_this.setData({
    imgSrc2: res.substring (Math.ceil(length / 2))
});

        如此就大功告成,图片能够正常显示了。  

相关文章:

  • 2021-10-22
  • 2021-10-25
  • 2022-12-23
  • 2021-07-29
  • 2021-10-08
  • 2021-10-26
猜你喜欢
  • 2021-11-28
  • 2022-01-19
  • 2021-12-13
  • 2021-07-11
  • 2022-12-23
  • 2021-10-01
相关资源
相似解决方案