html
<canvas id="myCanvas" width="400" height="400" style="border: 2px solid grey">當前瀏覽器不支持canvas</canvas>
js
var canvas = document.getElementById("myCanvas")
var context = canvas.getContext("2d")
var img = new Image()
img.src = 'paddle.png'
//圖片加載完后,將其顯示在canvas中
img.onload = function(){
context.drawImage(this, 0, 0)
// context.drawImage(this, 0, 0, 1080, 980)改變圖片大小到1080*980
}
之前犯了個錯誤是把2d寫成2D,就一直顯示不出來,鵝鵝鵝
