1
我使用下面的代码在画布上绘制了一个箭头。画布箭头不显示在Chrome中
window.onload = function() {
var canvas = document.getElementById("arrow");
var context = canvas.getContext("2d");
context.beginPath();
context.strokeStyle = "red";
context.fillStyle = "red";
context.moveTo(150, 400);
context.lineTo(400, 400);
context.lineTo(375, 375);
context.arcTo(400, 400, 375, 425, 35);
context.lineTo(400, 400);
context.stroke();
context.fill();
});
但是屏幕上没有显示箭头。
你设置'width'和画布的'height'属性? – CodeColorist