孜孜不倦的我又来提问了
- 当前 Bug 的表现(可附上截图) - 预期表现 - 复现路径 - 提供一个最简复现 Demo onShareAppMessage: function(e) { let that = this; console.log(e); if (e.target) { let videoId = e.target.dataset.videoId; let title = e.target.dataset.title; let cover = e.target.dataset.cover; console.log("videoId is " + videoId); console.log("title is " + title); console.log("cover is " + cover); // cover是一张网络图片(https,证书未过期) // ‘canvas’为前面创建的canvas标签的canvas-id属性值 let canvasW = 640; let canvasH = 420; if (750 / 420 > 5 / 4) { // 长宽比大于5:4 canvasW = 420 * 5 / 4; } // 将图片绘制到画布 ctx.drawImage(cover, (750 - canvasW) / 2, 0, canvasW, canvasH, 0, 0, canvasW, canvasH) // draw()必须要用到,并且需要在绘制成功后导出图片 ctx.draw(false,function(res) { // 导出图片 wx.canvasToTempFilePath({ width: canvasW, height: canvasH, destWidth: canvasW, destHeight: canvasH, canvasId: 'canvas', fileType: 'png', success: function(res) { let img = res.tempFilePath; console.log(img); return { title: title, imageUrl: img, path: "/pages/detail/detail?videoId=" + videoId } } }); }); } } -提问:为什么canvasToTempFilePath里面的return的object不生效,分享出去的还是默认截屏的图片,而不是我裁剪好的图片