請問我的代碼哪里出錯了
請問我這段代碼哪里有錯誤,為什么畫不出圓來
html代碼
? ? ?<div class="step">
? ? ? ? ? <canvas id="steps" width="440" height="90"></canvas>
? ? ?</div>
js代碼
? ? window.onload = function(){
? ? ? ? var canvas = document.getElementById("steps");
????????var cxt = canvas.getContext('2d');
? ? ? ? canvas.width =440;
? ? ? ? canvas.height = 90;
????????cxt.fillStyle="red";
????????cxt.arc(45, 45, 25, 0, 2*Math.PI, false);
????????cxt.fill();
}
2016-10-27
首先你在html中已經(jīng)給定過canvas的寬高,js中就不用重復(fù)設(shè)置了.
其次,你看看你的瀏覽器,IE9以下的不支持canvas。
我剛復(fù)制代碼發(fā)現(xiàn)是可以畫出圓的( ⊙ o ⊙ )!
2016-10-13
謝謝。
2016-10-12
把div去掉試試