我想反馈一个 问题:
自定义组件里定义
<canvas class=“papercanvas” canvas-id=“PaperCanvas” id=“PaperCanvas” bindtouchstart=“touchStart” bindtouchmove=“touchMove” bindtouchend=“touchEnd” bindtouchcancel=“touchCancel” binderror=“canvasError” disable-scroll=“true”></canvas>
绘图区域可以正常写字,调用微信API:
wx.canvasToTempFilePath({
canvasId: ‘PaperCanvas’,
success: function (res) {
console.log(res.tempFilePath);
},
fail: function (res) {
console.log(res);
}
结果:
errMsg:“canvasToTempFilePath:fail canvas is empty”
但是在普通页面调用此API就不会报错。
getHandWritingPng:function(){
var paperThis = this;
const app=getApp();
wx.canvasToTempFilePath({
canvasId: ‘PaperCanvas’,
success: function (res) {
console.log(“成功获取图片”+res.tempFilePath);
app.data.handwritingpath = res.tempFilePath
return res.tempFilePath
},
fail: function (res) {
console.log(res);
return ‘’
}
}, paperThis)
},