wx.canvasToTempFilePath({
x: 0,
y: 0,
width: 200,
height: 200,
//复制 * 750 / wx.getSystemInfoSync().windowWidth,换算成rpx;
destWidth: 500 * 750 / wx.getSystemInfoSync().windowWidth,
destHeight: 500 * 750 / wx.getSystemInfoSync().windowHeight,
canvasId: 'artQr',
success(res) {
console.log(res.tempFilePath)
that.setData({
qrImg: res.tempFilePath
})
}
})
本文介绍了一种使用微信小程序API实现canvas元素截图的方法。通过设置截图参数如宽度、高度及目标尺寸等,成功将canvas内容保存为临时文件并进一步用作二维码图片。文中详细展示了具体的实现代码。

7104

被折叠的 条评论
为什么被折叠?



