收藏
回答

canvasToTempFilePath报错fail jsapi invalid reques?

为什么在鸿蒙6.0手机的微信上面使用worker功能去做其他耗时操作后,canvasToTempFilePath就会报错:fail jsapi invalid request data。但是iOs和Android手机的微信都不会报错

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

2 个回答

  • 智能回答 智能回答 本次回答由AI生成
    04-20
    有用
    回复
  • ZHMʚ🐼ིྀɞ
    ZHMʚ🐼ིྀɞ
    04-20

                wx.canvasToTempFilePath({

                    x: 0,

                    y: 0,

                    width: that.resCanvasWidth / dpr,

                    height: that.resCanvasHeight / dpr,

                    destWidth: that.destWidth,

                    destHeight: that.destHeight,

                    canvas: exportCanvas,

                    success(res) {

                      console.log('canvasToTempFilePath success', res.tempFilePath);

                      resolve({

                        imagePath: res.tempFilePath,

                        width: that.destWidth,

                        height: that.destHeight,

                        dpr: dpr

                      });

                    },

                    fail(err) {

                      console.error('canvasToTempFilePath fail', err);

                      // 降级方案:尝试 toDataURL

                      console.warn('canvasToTempFilePath 失败,尝试 toDataURL 方案');

                      that.exportCanvasByDataURL(exportCanvas, dpr).then(resolve).catch(reject);

                    }

                  }, that);

    04-20
    有用
    回复
登录 后发表内容