用wx.getImageInfo来获取http://tmp/wx图片报错
发布于 5 年前 作者 xiuying56 17277 次浏览 来自 问答
  • 当前 Bug 的表现(可附上截图)

用wx.getImageInfo来获取 wx.canvasToTempFilePath 生成的

http://tmp/wx图片报接口错误

-预期效果:可获取转换图片,传给image标签,解决canvas层级高问题

  • 复现路径:必现
  • 提供一个最简复现 Demo

wx.canvasToTempFilePath({

canvasId: ‘aaa’,

quality: 1,

fileType: ‘png’,

success(res) {

    urlPath = res.tempFilePath;

    that.setData({ radarImg: urlPath });

 

    wx.getImageInfo({

        src: urlPath,//服务器返回的图片地址

        success: function (res) {

        Path = res.path;

        that.setData({

        radarImg: Path

        })

        },

        fail: function (res) {

        //失败回调

        console.log(res)

        }

    })

    },

    fail(res){

    console.log(res);

    }

    }, that)

2 回复

麻烦提供一下出现问题的机型和微信版本,并且给个相关的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html),我们定位下问题

  1. 机型基本都可复现

  2. 微信版本为6.7.3

  3. 基础库2.4.1

  4. 代码片段

  5. wx.canvasToTempFilePath({

  6. canvasId: 'lineGraph',

  7. quality: 1,

  8. fileType: 'png',

  9. success(res) {


  10. urlPath = res.tempFilePath;


  11. that.setData({ radarImg: urlPath });



  12. wx.getImageInfo({

  13. src: urlPath,

  14. success: function (res) {



  15. Path = res.path;


  16. that.setData({

  17. radarImg: Path

  18. })

  19. },

  20. fail: function (res) {


  21. console.log(res)

  22. }

  23. })

  24. },

  25. fail(res){

  26. console.log(res);

  27. }

  28. }, that)

回到顶部