You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
参数 类型 必填 说明 最低版本
x Number 否 画布x轴起点(默认0) 1.2.0
y Number 否 画布y轴起点(默认0) 1.2.0
width Number 否 画布宽度(默认为canvas宽度-x) 1.2.0
height Number 否 画布高度(默认为canvas高度-y) 1.2.0
destWidth Number 否 输出图片宽度(默认为width) 1.2.0
destHeight Number 否 输出图片高度(默认为height) 1.2.0
canvasId String 是 画布标识,传入 的 cavas-id
success Function 否 接口调用成功的回调函数
fail Function 否 接口调用失败的回调函数
complete Function 否 接口调用结束的回调函数(调用成功、失败都会执行)
根据wx的官方文档 canvasToTempFilePath api是可以自适应的,是否可以考虑在调用api时候使用自适应来达到截图自适应,而且现在确实出现了截图后宽高失真的情况
wx.canvasToTempFilePath(OBJECT)
把当前画布指定区域的内容导出生成指定大小的图片,并返回文件路径。
OBJECT参数说明:
参数 类型 必填 说明 最低版本
x Number 否 画布x轴起点(默认0) 1.2.0
y Number 否 画布y轴起点(默认0) 1.2.0
width Number 否 画布宽度(默认为canvas宽度-x) 1.2.0
height Number 否 画布高度(默认为canvas高度-y) 1.2.0
destWidth Number 否 输出图片宽度(默认为width) 1.2.0
destHeight Number 否 输出图片高度(默认为height) 1.2.0
canvasId String 是 画布标识,传入 的 cavas-id
success Function 否 接口调用成功的回调函数
fail Function 否 接口调用失败的回调函数
complete Function 否 接口调用结束的回调函数(调用成功、失败都会执行)
示例代码
wx.canvasToTempFilePath({
x: 100,
y: 200,
width: 50,
height: 50,
destWidth: 100,
destHeight: 100,
canvasId: 'myCanvas',
success: function(res) {
console.log(res.tempFilePath)
}
})
The text was updated successfully, but these errors were encountered: