請(qǐng)問(wèn)我的代碼哪里出錯(cuò)了
請(qǐng)問(wèn)我這段代碼哪里有錯(cuò)誤,為什么畫(huà)不出圓來(lái)
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)給定過(guò)canvas的寬高,js中就不用重復(fù)設(shè)置了.
其次,你看看你的瀏覽器,IE9以下的不支持canvas。
我剛復(fù)制代碼發(fā)現(xiàn)是可以畫(huà)出圓的( ⊙ o ⊙ )!
2016-10-13
謝謝。
2016-10-12
把div去掉試試