目前用这个方案,但是这个方案的width和height有点问题。有目标节点以外的东西也同时截到了。求分享图长宽的正式计算方式。
canvas.toTempFilePath({
x: -nodeShare.width,
y: 0,
width: nodeShare.width,
height: nodeShare.height,
destWidth: nodeShare.width,
destHeight: nodeShare.height,
fileType: “png”,
success: (res) => {
console.log(“targetNode success”);
let imagUrl = res.tempFilePath;
wx.shareAppMessage({
title: “titleString”,
imageUrl: imagUrl,
success: function (params) {
console.log(‘share: tuyoo shareAppMessage success, params:’ + JSON.stringify(params));
// if (succCallback) {
// succCallback(params);
// }
},
fail: function (params) {
console.log('share: tuyoo shareAppMessage fail, params:' + JSON.stringify(params));
// if (failCallback) {
// failCallback(params);
// }
},
});
},
fail: function (params) {
console.log('share: tuyoo showShareMenu fail, params:' + JSON.stringify(params));
},
});