Back to Uni App

Canvas To Temp File Path

docs/api/canvas-to-temp-file-path.md

2.3.35.1 KB
Original Source

uni.canvasToTempFilePath(options, componentInstance) @canvastotempfilepath

把当前画布指定区域的内容导出生成指定大小的图片

canvasToTempFilePath 兼容性

Web微信小程序AndroidiOSHarmonyOS
4.04.41<a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a><a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a><a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a>
  • 截图或海报需求,app平台view直接提供截图API,takesnapshot

参数

名称类型必填默认值兼容性描述
optionsCanvasToTempFilePathOptions-Web: -; 微信小程序: -; Android: x; iOS: x; HarmonyOS: x
componentInstanceany-Web: -; 微信小程序: -; Android: x; iOS: x; HarmonyOS: x

options 的属性描述

名称类型必备默认值兼容性描述
xnumber-Web: -; 微信小程序: 4.41; Android: x; iOS: x; HarmonyOS: x画布x轴起点(默认0)
ynumber-Web: -; 微信小程序: 4.41; Android: x; iOS: x; HarmonyOS: x画布y轴起点(默认0)
widthnumber-Web: -; 微信小程序: 4.41; Android: x; iOS: x; HarmonyOS: x画布宽度(默认为canvas宽度-x)
heightnumber-Web: -; 微信小程序: 4.41; Android: x; iOS: x; HarmonyOS: x画布高度(默认为canvas高度-y)
destWidthnumber-Web: -; 微信小程序: 4.41; Android: x; iOS: x; HarmonyOS: x输出图片宽度(默认为 width * 屏幕像素密度)
destHeightnumber-Web: -; 微信小程序: 4.41; Android: x; iOS: x; HarmonyOS: x输出图片高度(默认为 height * 屏幕像素密度)
canvasIdstring-Web: -; 微信小程序: 4.41; Android: x; iOS: x; HarmonyOS: x画布标识,传入 <canvas/> 的 canvas-id
fileTypestring-Web: -; 微信小程序: 4.41; Android: x; iOS: x; HarmonyOS: x目标文件的类型,默认为 'png'
qualitynumber-Web: -; 微信小程序: 4.41; Android: x; iOS: x; HarmonyOS: x图片的质量,取值范围为 (0, 1],不在范围内时当作1.0处理
success(result: CanvasToTempFilePathSuccess) => void-Web: -; 微信小程序: 4.41; Android: x; iOS: x; HarmonyOS: x接口调用成功的回调函数
fail(result: UniError) => void-Web: -; 微信小程序: 4.41; Android: x; iOS: x; HarmonyOS: x接口调用失败的回调函数
complete(result: any) => void-Web: -; 微信小程序: 4.41; Android: x; iOS: x; HarmonyOS: x接口调用结束的回调函数(调用成功、失败都会执行)
canvasany-Web: -; 微信小程序: 4.41; Android: x; iOS: x; HarmonyOS: x

CanvasToTempFilePathSuccess 的属性值 @canvastotempfilepathsuccess-values

名称类型必备默认值兼容性描述
tempFilePathstring-Web: -; 微信小程序: 4.41; Android: x; iOS: x; HarmonyOS: x导出生成的图片路径
errMsgstring-Web: -; 微信小程序: -; Android: x; iOS: x; HarmonyOS: x

参见

通用类型

GeneralCallbackResult

名称类型必备默认值兼容性描述
errMsgstring-Web: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: -错误信息