1. stroke
beginPath endPath 只是路径,没有真正的画线,真正的画线是stroke
$(function(){var canvas = $("#canvas")[0];var context = canvas.getContext('2d');context.beginPath();context.moveTo(3,3);context.lineTo(200,200);// context.stroke();context.endPath();})
如上这段代码,如果没有放开stroke的话,网页什么都没有显示,放开stroke后,网页才出现一条直线。