<canvas id="screenshot" type="2d"></canvas>
function initCanvas(canvas, fullScreen, pixelRatio)
{
let SystemInfo = wx.getSystemInfoSync()
canvas.pixelRatio = pixelRatio || SystemInfo.pixelRatio;
if (fullScreen){
canvas.width = SystemInfo.windowWidth * canvas.pixelRatio;
canvas.height = SystemInfo.windowHeight * canvas.pixelRatio;
}else{
canvas.width *= canvas.pixelRatio;
canvas.height *= canvas.pixelRatio;
}
return canvas
}
wx.createSelectorQuery().selectAll('screenshot').node(res => {
shotCanvas =initCanvas(res[0].node,false,2)
shotCtx = shotCanvas.getContext('2d')
}).exec()
let let img = shotCanvas.createImage()
img.onload = () => {
wx.canvasToTempFilePath({
canvas: shotCanvas,
quality: 0.4,
success: function success(res) {}
}
img.src="xxx"