我想在html2canvas(document.body).then(function(canvas){}); click
上调用javaScript
函数中的button
。
工作守则:
function action () {
if (elementScope == "body") {
alert("generating pdf.........2");
//alert("canvas........."+canvas)
alert("document.body......."+document.body)
//mypdf();
html2canvas(document.body).then(function(canvas){
alert("html2canvas called...!!!");
var imageFullQuality = canvas.toDataURL();
var docDefinition = {
content: [{
image : imageFullQuality,
width : widthCanvas,
}]
};
alert("generating pdf.........4");
new pdfMake.createPdf(docDefinition).download(fileName + ".pdf");
});
}
}
错误码
没有调用的html2canvas(document.body).then(function(canvas){});和剩余的代码将正确执行。
this.action = function action() {
if (elementScope == "body") {
alert("generating pdf.........2");
//alert("canvas........."+canvas)
alert("document.body......."+document.body)
//mypdf();
html2canvas(document.body).then(function(canvas){
alert("html2canvas called...!!!");
var imageFullQuality = canvas.toDataURL();
var docDefinition = {
content: [{
image : imageFullQuality,
width : widthCanvas,
}]
};
alert("generating pdf.........4");
new pdfMake.createPdf(docDefinition).download(fileName + ".pdf");
});
}
}
这里的问题是什么。请帮帮我。
发布于 2019-02-12 03:32:28
您可以直接赋值函数而不是分配function action() {}
。
this.action => () {
if (elementScope == "body") {
alert("generating pdf.........2");
//alert("canvas........."+canvas)
alert("document.body......."+document.body)
//mypdf();
html2canvas(document.body).then(function(canvas){
alert("html2canvas called...!!!");
var imageFullQuality = canvas.toDataURL();
var docDefinition = {
content: [{
image : imageFullQuality,
width : widthCanvas,
}]
};
alert("generating pdf.........4");
new pdfMake.createPdf(docDefinition).download(fileName + ".pdf");
});
}
}
https://stackoverflow.com/questions/54648819
复制相似问题