我有以下用户片段:
{
/*
// Place your snippets for JavaScript React here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
"Print to console": {
"prefix": "log",
"body": [
"console.log('$1');",
"$2"
],
"description": "Log output to console"
}
*/
"Small comment": {
"prefix": "//=",
"body": [
"// ===================================",
"// ${1:COMMENT}",
"// ==================================="
],
"description": "Small comment"
}
}
我在第二条正文行出现以下错误:
Invalid characters in string. Control characters must be escaped.
我认为${1:somestring}
是有效的占位符。构建此代码段时我做错了什么?
[我只是在寻找答案时发现了这个问题,我使用了代码片段生成器,因此假设每种格式都相同,但是我不认为我粘贴了带有选项卡的代码。
删除选项卡并使用空格代替格式来修复它。
希望这会有所帮助。 :)