<!DOCTYPE?html>
<html>
<head>
????<title></title>
????<meta?charset="utf-8">
????<style?type="text/css"></style>
</head>
<body>
????<canvas?id="canvas"style="border:1px?solid?#aaa;display:block;margin:50px?auto;"></canvas>
????<script>
????????window.onload=function(){
????????????var?canvas=document.getElementById("canvas");
????????????canvas.height=768;
????????????canvas.width=1024;
????????????var?context=canvas.getContext("2d");
????????????drawRect(context,100,100,400,400,20,"green","red");
????????}
????????function?drawRect(cxt,x,y,width,height,borderWidth,borerColor,fillColor){
????????????cxt.beginPath();
????????????cxt.moveTo(x,y);
????????????cxt.lineTo(x?+?width,y);
????????????cxt.lineTo(x?+?width,y?+?height);
????????????cxt.lineTo(x,y?+?height);
????????????cxt.lineTo(x,y);
????????????cxt.closePath();
????????????
????????????cxt.lineWidth="borderWidth";
????????????cxt.fillStyle="fillColor";
????????????cxt.strokeStyle="borerColor";
????????????
????????????cxt.fill();
????????????cxt.stroke();
????????}
????????
????</script>
</body>
</html>

2015-10-04
fillColor和borerColor是變量,不能用引號(hào)。
2015-10-04
這個(gè)也是相同的問(wèn)題
2015-10-04
真的是完全檢測(cè)不出bug,好憂傷