wx.canvasToTempFilePath 返回的地址image无法显示
发布于 5 年前 作者 huguiying 3613 次浏览 来自 问答

wx.canvasToTempFilePath 返回的地址image无法显示

IDE版本:v1.02.1802080

问题:使用wx.canvasToTempFilePath代码如下

//js

let w = 750 * this.data.scale;

let h = 1331 * this.data.scale;
wx.canvasToTempFilePath({
   x: 0,
   y: 0,
   width: w,
   height: h,
   destWidth: w,
   destHeight: h,
   fileType: 'jpg',
   canvasId: 'canvas-demo',
   success: (res) => {
      this.setData({
         resultImg: res.tempFilePath
      });
      wx.hideLoading();
   }

})


//wxml

<image style='width:100%;height:100%' src='{{resultImg}}'></image>



VM10634:2 Failed to load image http://tmp/wx29b36995dd2d651d.o6zAJsylq9Cfw8ycQlyhqBBjOUhM.83919b7049fe20ff87cff1c78bcae1f6.jpg

the server responded with a status of 404 (HTTP/1.1 404 Not Found) 

From server 127.0.0.1

报错提示 如上面 但是真机不会

顺便说一下 IDE没有更新之前做过一个项目 是没有这个问题的

2 回复

勾选了"不校验安全域名、web-view 域名、TLS 版本以及 HTTPS 证书"…还是不行…更新之前写的项目可以看这个路径的图片,更新之后的就不行了

我之前碰到这个问题的解决办法:


  1. 关掉本地代理

  2. 重启一下调试器

  3. 在调试器里勾选"不校验安全域名、web-view 域名、TLS 版本以及 HTTPS 证书"

回到顶部