[英]how to return value from this javascript function
I'm working with html2canvas and I have the next function 我正在使用html2canvas ,下一个功能是
hml2canvas($('body'), {
onrendered: function(canvas) {
data = canvas.toDataURL('image/jpeg');
}
});
Now, I want to return the data value, so I tried this 现在,我想返回数据值,所以我尝试了
html2canvas($('body'), {
onrendered: (this, imgBase64)
});
var data;
function imgBase64(canvas) {
data = canvas.toDataURL('image/jpeg');
}
console.log(data);
but when I see the console I get "undefined". 但是当我看到控制台时,我得到“未定义”。 If I put
console.log(data);
如果我把
console.log(data);
inside the imgBase64
function I get the base64 of the image, but I need the data
out of that function to make another work with it. 在
imgBase64
函数中,我获得了图像的base64,但是我需要该函数中的data
来进行其他处理。 Any ideas? 有任何想法吗? Thanks.
谢谢。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.