本人新手,想用canvas弄个三角形,填充红色,但浏览器没显示我要的结果,这是为什么
<!doctype html> <html> <meta charset="utf-8"> <head> <title>随笔</title> </head> <body> <canvas id="canvas"></canvas> <script> var canvas = document.getElementById('canvas'); var context = canvas.getContext('2d'); context.beginPath() context.moveTo(50,50) context.lineTo(50,100) context.lineTo(60,60) context.lineTo(50,50) context.closePath() context.fillStyle("#FF0000") context.fill() </script> </body> </html>