更改用户代码段I后,想使用它。
除了重新启动VSCode之外,还有其他方法可以更新代码段吗?
答案 0 :(得分:0)
当我将代码片段放入错误的代码片段文件时,我遇到了这个问题。例如,我想编写一个新的片段来创建一个 React 函数组件,如下所示:
{
// Place your snippets for typescriptreact 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"
// }
"React Function Component": {
"prefix": "reactfc",
"body": [
"export type ${2:Props} = {",
"};",
"",
"export const ${1:Component}: React.FC<${2:Props}> = props => {",
" return (",
" <>$0</>",
" );",
"};"
],
"description": "Create a new React Function Component with types"
}
}
但我不小心把它放在了 typescript.json
片段文件而不是 typescriptreact.json
片段文件中。将其移动到正确的片段文件中使其被正确拾取。这可能是这里的问题。
无论如何,我在这里写这个答案是因为这是试图找到这个问题的解决方案时出现的搜索。