无法找出用户片段
我试图在 VSCode 中创建另一个用户片段来自动化 document.querySelector
但每当我尝试时,它都会给我一个奇怪的错误,如下所示。我有另一个片段,效果很好,但这是我正在参加的在线课程向我展示的。我对 json
没有任何经验,所以我可能只是语法错误,但它与我之前的代码片段完全相同。
如果该链接不起作用,我将添加下面编写的代码。我收到的错误是在第一个花括号上,它显示 “文件结尾预期 .json”
感谢所有帮助:)
{ // start of file and json object
// other snippets here
"query selector": {
"scope": "javascript",
"prefix": "dq",
"body": ["document.querySelector('$0')"],
"description": "Select element from document"
},
// other snippets here
} // end of json object
I am trying to make another user snippet in VSCode to automate the document.querySelector
but whenever I try to it gives me a weird error shown below. I have another snippet that works just fine but that was shown to me by an online class I am taking. I don't have any experience with json
so I may just be getting the syntax wrong but it is the exact same as my previous snippet.
In case that link doesn't work I'll include the code written below. The error I am getting is on the very first curly brace and it says "end of file expected .json"
All help is appreciated :)
{ // start of file and json object
// other snippets here
"query selector": {
"scope": "javascript",
"prefix": "dq",
"body": ["document.querySelector('$0')"],
"description": "Select element from document"
},
// other snippets here
} // end of json object
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的JSON文件不正确。
您应该将对象从上面的JSON对象内部放置为“查询选择器”。
在第14行中的卷曲支架后添加逗号,然后在其中添加片段。从第17和24行删除外部卷曲括号。JSON
文件只是一个对象。
因此,您的摘要文件看起来像这样:
顺便说一句,我认为您不需要
“ scope”
键。Your json file is incorrect.
You should place the object starting with the key “query selector” inside the json object above.
Add a comma after the curly brace in line 14 and add your snippet in there. Remove your outer curly braces from lines 17 and 24.
Json files are only one single object.
So your snippets file would look something like this:
By the way, I don't think you need the
"scope"
key.使用方括号开始 json 文件,并以方括号 [ ] 结束。
Use a square bracket to start a json file, and end with a square bracket [ ].