js加载异常或未找到是什么意思

JavaScript014

js加载异常或未找到是什么意思,第1张

js没有引入成功。

导致这个报错的原因可能是引入js的路径不对或者是js的名称错误,请检查。

JavaScript(简称“JS”)是一种具有函数优先的轻量级,解释型或即时编译型的编程语言。虽然它是作为开发Web页面的脚本语言而出名,但是它也被用到了很多非浏览器环境中,JavaScript基于原型编程、多范式的动态脚本语言,并且支持面向对象、命令式、声明式、函数式编程范式。

你这个代码看起来没问题,但是其中有些地方的符号是全角的,所以导致出错,建议重新写吧,在英文半角状态下编写代码

然后就是变量定义的位置有点问题。

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/htmlcharset=UTF-8" />

<title>Throwing 1 die</title>

<script type="text/javascript" >

var cwidth = 400//保存画布的宽度

var cheight = 300//保存画布的高度

var dicex = 50//保存骰子的水平位置

var dicey = 50//保存骰子的垂直位置

var dicewidth = 100//保存骰子的宽度

var diceheight = 100//保存骰子的高度

var dotrad = 6//骰子的半径

var ctx

function init()

{

ctx = document.getElementById('c1').getContext('2d')

ctx.fillRect(50,50,100,100)

drawface(1)

}

function drawface(n)

{

ctx.lineWidth = 5//设置骰子的边框的厚度

ctx.clearRect(dicex,dicey,dicewidth,diceheight)//清除原来画的骰子

ctx.strokeRect(dicex,dicey,dicewidth,diceheight)//画骰子

ctx.fillStyle = "#009966"//设置园的颜色

switch(n)

{

//判断n是几

case 1: Draw1()

break

case 2: Draw2()

break

}

}

function Draw1()

{

var dotx//保存单个圆点的水平位置

var doty//保存单个圆点的垂直位置

ctx = document.getElementById('c1').getContext('2d')

dotx = dicex + dicewidth * 0.5

doty = dicey + diceheight * 0.5

ctx.beginPath()//开始路径

ctx.arc(dotx,doty,dotrad,0,Math.PI* 2,true)//画圆

ctx.closePath()//结束路径

ctx.fill()//填充圆

}

function Draw2()

{

var dotx

var dotyctx = document.getElementById('c1').getContext('2d')

dotx = dicex + dotrad * 3

doty = dicey + dotrad * 3

ctx.beginPath()

ctx.arc(dotx,doty,dotrad,0,Math.PI*2,true)

dotx = dicex + dicewidth - dotrad * 3

doty = dicey + diceheight - dotrad * 3

ctx.arc(dotx,doty,dotrad,0,Math.PI * 2,true)

ctx.closePath()

ctx.fill()

}

</script>

</head>

<body onload="init()">

<canvas id="c1" width="400" height="300">your browers </canvas>

</body>

</html>

这个是帮你修改后的代码。