请问为什么显示不出来
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<style type="text/css">
#cvs{
/*border: solid 1px red;*/
display: block;
margin: 0 auto;
}
</style>
</head>
<body>
<canvas id="cvs"></canvas>
<script type="text/javascript">
var tang =[
{p:[{x:0,y:0},{x:800,y:0},{x:400,y:400}],color:"#dddddd"},
{p:[{x:0,y:0},{x:400,y:400},{x:0,y:800}],color:"#dddddd"},
{p:[{x:800,y:0},{x:800,y:400},{x:600,y:600},{x:600,y:200}],color:"#dddddd"},
{p:[{x:600,y:200},{x:600,y:600},{x:400,y:400}],color:"#dddddd"},
{p:[{x:400,y:400},{x:600,y:600},{x:400,y:800},{x:200,y:600}],color:"#dddddd"},
{p:[{x:200,y:600},{x:400,y:800},{x:0,y:800}],color:"#dddddd"},
{p:[{x:800,y:400},{x:800,y:800},{x:400,y:800}],color:"#ed4259"}
]
window.onload = function(){
console.log(tang);
var canvas =document.getElementById("cvs");
canvas.width = 800;
canvas.height =800;
var context =canvas.getContext("2d");
for(var i =0;i<tang.length;i++){
draw(tang[i],context)
}
}
function draw(nums,ctx){
ctx.beginPath();
ctx.moveTo(nums.p[0].x,nums.p[0].y);
for(var i=1;i<nums.p.legth;i++){
ctx.lineTo(nums.p[i].x,nums.p[i].y);
}
ctx.closePath();
ctx.fillStyle=nums.color;
ctx.fill();
}
</script>
</body>
</html>