棋盘的斜线出不来,为什么

js的代码

window.onload = function () {

var chess = document.getElementById('chess');

var context = chess.getContext('2d');

context.srtokeStyle = "#BFBFBF";

context.moveTo(0,0);

context.lineTo(450,450);

context.stroke();

}

index的代码

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>五子棋</title>

<link rel="stylesheet" type="text/css" href="CSS/style.css">

</head>

<body>

<canvas id = "chess" width = "450px" height = "450px"></canvas>

<script type="text/javascript" scr="js/script.js"></script>

</body>

</html>


Sherlock3515984
浏览 1093回答 2
2回答

慕瓜9542731

是src,拼写错误。

zhaosixing

试一试给canvas加一个边框看看宽高是否被撑起来了,如果没有撑起来吧px属性给去掉再看看
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript