Javascript VSCode语法错误;预期
我不确定这是否真的是一个问题,正如我在过去注意到的那样,VSCode给出了只适用于TypeScript的警告。我正在vanilla JS中创建一个对象构造函数,如下所示:Javascript VSCode语法错误;预期,javascript,visual-studio-code,Javascript,Visual Studio Code,我不确定这是否真的是一个问题,正如我在过去注意到的那样,VSCode给出了只适用于TypeScript的警告。我正在vanilla JS中创建一个对象构造函数,如下所示: "use strict"; function Imaging(outputAttr) { var output = document.getElementById(outputAttr); var svgAttributes = { namespace: ['http://www.w3.org
"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 SvgatAttributes下,我得到了一个红色的带有错误的曲线;预期。据我所知,一切都正常工作,但我不确定为什么我在编辑器中会出现这个错误。我错过什么了吗
我在评论中注意到了确切的位置。我认为这是因为您必须添加一个;在功能成像的末尾,如下所示:
"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
这似乎不是问题所在。考虑到分号在这里被认为是可选的,这正是我所期望的。我不喜欢忽略错误,但我可能需要把这归因于编辑的古怪,因为它还没有真正影响到任何事情。谢谢