VSCode语法错误;预期
VSCode Syntax Error ; expected
不确定这是否真的是一个问题,正如我在过去注意到的那样,VSCode会对只适用于TypeScript的东西发出警告。我正在香草JS中创建一个对象构造函数,如下所示:
"use strict";
function Imaging(outputAttr) {
var output = document.getElementById(outputAttr);
var svgAttributes = {
namespace: ['http://www.w3.org/2000/svg', 'svg'],
attributes: { // colon here
style: "border: 1px solid black", //d in border, b in black
width: "200", height: "300" }, //t in width
attributeNamespace : ['http://www.w3.org/2000/xmlns/', 'xmlns:xlink', 'http://www.w3.org/1999/xlink']
};
}
在var svgAttributes
下,我得到一个红色的歪歪扭扭,错误为"; expected"
。据我所知,一切都正常,但我不确定为什么我在编辑器中出现这个错误。我是不是错过了什么?
我在评论中注意到了确切的位置。
我认为这是因为你必须在function Imaging
的末尾添加一个;
,如下所示:
"use strict";
function Imaging(outputAttr) {
var output = document.getElementById(outputAttr);
var svgAttributes = {
namespace: ['http://www.w3.org/2000/svg', 'svg'],
attributes: { // colon here
style: "border: 1px solid black", //d in border, b in black
width: "200", height: "300" }, //t in width
attributeNamespace : ['http://www.w3.org/2000/xmlns/', 'xmlns:xlink', 'http://www.w3.org/1999/xlink']
};
}; // <----- just here
相关文章:
- 预期响应包含一个对象,但在angular js中得到一个数组错误
- j查询对象预期错误
- [function].apply() 导致 IE 中出现“JScript 对象预期”错误
- JavaScript 对象 _doPostBack('','') 中的预期错误
- 自动完成脚本收到对象预期错误
- 柴:是否预期错误取决于参数
- Angular VS 2015 MVC自定义指令意外标识符和预期;错误
- Objected预期错误Javascript/Jquery
- 导致对象的Javascript外部文件IE8(Marketo)中出现预期错误
- Why Object在jquery中预期错误
- Internet Explorer对象预期错误
- IE8获取对象预期错误-在var关键字声明XMLHttpRequest对象时发生
- 使用A+承诺处理预期错误和操作错误
- IE8对象预期错误
- 在使用skrollr.min.js插件的IE8上出现对象预期错误
- Javascript 代码对象预期错误
- addEventListener代码块中的函数预期错误
- IE在比较字符串时的预期错误数
- 消息:IE8中的对象预期错误
- IE预期')'错误