javascript 未捕获的语法错误:第一行的输入意外结束
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22726516/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Uncaught SyntaxError: Unexpected end of input on line one
提问by FracturedRetina
This error is usually associated with messy close parens, but I'm getting the error on line 1of the file!
此错误通常与混乱的关闭括号相关联,但我在文件的第 1 行收到错误!
Here's the javascript(filename: calculate.js)
这是javascript(filename: calculate.js)
var colors = new Array();
colors["SILVER"] = -2;
...
There's plenty more code later in the file, but I don't think it could be causing this error.
文件后面还有更多代码,但我认为这不会导致此错误。
And in case this is caused by the head declarations, here's the document head.
如果这是由头部声明引起的,这里是文档头部。
<meta id="author" content="Dawson Diaz, Evan Shimoniak">
<meta id="description" content="Resistor Color Code Calculator">
<meta id="keywords" content="Resistor, Calculator, Color Code, Electronics">
<!--Set favicon-->
<link href="favicon.ico" rel="icon" type="image/x-icon" />
<!--Include jQuery-->
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<!-- Latest Bootstrap minified CSS -->
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
<!-- Custom CSS -->
<link rel="stylesheet" href="style.css">
<!--Latest compiled and minified Bootsrap JavaScript-->
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
<!--Calculator-->
<script src="calculate.js" type="text/javascript"></script>
<!--Input processing-->
<script src="ui.js" type="text/javascript"></script>
Any advice is appreciated.
任何建议表示赞赏。
EDIT:The full code for calculate.js is here
编辑:calculate.js 的完整代码在这里
采纳答案by dave
You're missing a }
at the end of your getResistanceStr
function. Don't know why it says line 1 but that is the problem.
您在函数}
末尾缺少 a getResistanceStr
。不知道为什么它说第 1 行,但这就是问题所在。