Javascript Html2Canvas:为什么这不起作用?

Javascript Html2Canvas:为什么这不起作用?,javascript,html,canvas,screenshot,Javascript,Html,Canvas,Screenshot,要想弄明白这为什么不起作用,它应该在加载时截取一个“Hello”的屏幕截图,但它什么也没做 感谢所有能帮助我的人,我不熟悉javascript,我只是用它来实现这个功能 <html> <body> <script src="html2canvas.js"> window.onload = function(){ html2canvas(document.body, { onrendered: function(canvas) { d

要想弄明白这为什么不起作用,它应该在加载时截取一个“Hello”的屏幕截图,但它什么也没做

感谢所有能帮助我的人,我不熟悉javascript,我只是用它来实现这个功能

<html>
<body>
<script src="html2canvas.js">
  window.onload = function(){
    html2canvas(document.body, {
    onrendered: function(canvas) {
    document.body.appendChild(canvas);
    },
width: 300,
height: 300
})};
</script>
</body>
<h1>Hello</h1>

<canvas id="canvas" width="300" height="300" style="border:1px solid      #d3d3d3;">

</html>

window.onload=函数(){
html2canvas(document.body{
onrendered:函数(画布){
document.body.appendChild(画布);
},
宽度:300,
身高:300
})};
你好
试试这个

    <html>
<body>
<script src="html2canvas.js">
  window.onload = function(){
    html2canvas(document.body, {
    onrendered: function(canvas) {
    document.body.appendChild(canvas);
    },
width: 300,
height: 300
})};
</script>
<h1>Hello</h1>

<canvas id="canvas" width="300" height="300" style="border:1px solid      #d3d3d3;">
</body>


</html>

window.onload=函数(){
html2canvas(document.body{
onrendered:函数(画布){
document.body.appendChild(画布);
},
宽度:300,
身高:300
})};
你好

在和标记中移动画布和h1标记。

我仍然得到一个空白画布@Ricky你看过文档了吗?我想你的html2canvas.js和那篇HTML文件在同一个目录下。。。p、 您不需要创建画布,html2canvas函数会为您返回一个画布