<!doctype html>
<html>
<head>
<meta name="viewport" content="width=device-width,initial-scale=1">
<title></title>
<style>
div{
text-align: center;
margin-top: 250px;
}
#clock{
border: 1px solid #ccc;
}
</style>
</head>
<body>
<div>
<canvas id="clock" height="200" width="200"></canvas>
</div>
<script type="text/javascript">
var dom = document.getElementById('clock');
var ctx = dom.getContext('2b');
var width = ctx.canvas.width;
var height = ctx.canvas.height;
var r = width / 2;
function drawBackground() {
ctx.translate(r, r);
ctx.beginPath();
ctx.lineWidth = 10;
ctx.arc(0, 0, r - 5, 0, 2*Math.PI, false);
ctx.stroke();
}
drawBackground();
</script>
</body>
</html>
把2b改成2d ,真逗