收藏
回答

使用wx.canvasToTempFilePath不能保存图片?

// view
<canvas type="2d" canvas-id="myCanvas" id="myCanvas" class="myCanvas"></canvas>
// js
wx.canvasToTempFilePath({ //将canvas生成图片
      canvasId: 'myCanvas',
      x: 0,
      y: 0,
      width: 300,
      height: 450,
      success: function (res) {
        let {
          tempFilePath
        } = res.tempFilePath //图片临时路径
        // let urls = '../../image/guide.jpg' //图片临时路径
        wx.saveImageToPhotosAlbum({
          filePath: tempFilePath, //canvasToTempFilePath返回的tempFilePath
          success: (res) => {
            console.log(tempFilePath)
          },
          fail: (err) => {}
        })
      }
    }, this)
  }
// 报错
call failed:, {errMsg: "canvasToTempFilePath:fail fail canvas is empty"}
回答关注问题邀请回答
收藏

1 个回答

登录 后发表内容