所以我正在做一个小项目,只是为了好玩,我学到了一些关于画布的东西,我写了一个脚本(现在已经不见了)只是在画布上画一个图像,它不起作用所以我删除了它。所以我去了 w3schools 并拿了他们的示例代码,它仍然无法正常工作。您可以在这里查看:http: //zach.muny.us/widgets/onlineedit我没有收到任何错误,什么也没有。只是希望有人知道修复oO
<!DOCTYPE html>
<html>
<body>
<p>Image to use:</p>
<img id="scream" src="http://www.w3schools.com/html/img_the_scream.jpg" alt="The Scream" width="220" height="277"><p>Canvas:</p>
<canvas id="myCanvas" width="250" height="300" style="border:1px solid #d3d3d3;">
Your browser does not support the HTML5 canvas tag.</canvas>
<script>
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
var img=document.getElementById("scream");
ctx.drawImage(img,10,10);
</script>
</body>
</html>