第一次用优快云写文章,在这里主要记录一下我在写代码时候遇到的问题,之前一直没有注册.因为注册时候没有英国号码的选项。
我用的是Atoms编译器,刚开始学习的时候,在运用里面的package"script" 来运行代码时候会出现bug:
You must select a language in the lower right, or save the file with an appropriate extension…
例如下面这个例子
function setup()
{
//create a canvas for the robot
createCanvas(500, 500);
}
function draw()
{
strokeWeight(6);
//robots head
fill(200);
rect(100, 100, 300, 300, 20);
//robots antenna
fill(250, 250, 0);
ellipse(250, 70, 60, 60);
fill(200, 0, 200);
rect(50, 80, 80, 30);
//robots eyes
fill(255);
ellipse(175, 200, 80, 80);
point(175, 200);
ellipse(325, 200, 80, 80);
point(325, 200);
//robots nose
fill(255, 0, 0);
triangle(250, 220, 200, 300, 300, 300);
//robots ears
rect(80, 180, 30, 100);
rect(390, 180, 30, 100);
//robots mouth
noFill();
beginShape();
vertex(175, 340);
vertex(200, 370);
vertex(225, 340);
vertex(250, 370);
vertex(275, 340);
vertex(300, 370);
vertex(325, 340);
endShape();
}
这是一个我在Coursera上课时候Tutor给的很正常的一个代码,但是在Atoms里面却报错。主要原因是保存的文件名字没有写上后缀,Atoms不知道你写的是什么Language。
解决的方法就是>
把文件名字加上后缀,例如我这里写的是JavaScript,文件就要加上后缀名.js
如果使用Python写的,文件后缀名就要加上.py

本文记录了在Atom编辑器中使用JavaScript时遇到的常见错误:“You must select a language in the lower right...”及解决方案。错误源于未指定文件的编程语言,通过为文件添加正确的后缀名(如.js)即可解决。
757

被折叠的 条评论
为什么被折叠?



