简体   繁体   English

VSCode 中 Svelte 的用户代码段

[英]User Snippets for Svelte in VSCode

I struggle to create a simple snippet for.svelte files or Svelte project.我很难为 .svelte 文件或 Svelte 项目创建一个简单的片段。 Here's the procedure i've tried:这是我尝试过的程序:

  1. Ctrl + Maj + P to open "Preference: Configure user Snippets" Ctrl + Maj + P 打开“首选项:配置用户片段”
  2. New Global Snippets File... typed svelte to create the svelte.json file新的全局片段文件...键入 svelte 以创建 svelte.json 文件
  3. Inside of it the below code在它里面是下面的代码
{
  "test": {
    "scope": "Svelte",
    "prefix": "xx",
    "body": ["This is a simple test"],
    "description": "Code snippet for testing"
  }
}

Any idea?任何想法?

The scope id for Svelte is probably svelte lowercase. Svelte 的svelte id 可能是小写的。 If you click on the Svelte language id button in the lower right when you have a .svelte file open, you can look through those language ids for svelte - the correct version to use is that in the parentheses like如果在打开.svelte文件时单击右下角的Svelte语言 ID 按钮,则可以查看svelte的这些语言 ID - 要使用的正确版本是括号中的版本,例如

Svelte (svelte) use the version in parentheses - svelte lowercased Svelte (svelte)使用括号中的版本 - svelte小写

You do not need to remove the scope selector but it is redundant if it is already inside the svelte.json file which limits all snippets within it to that filetype.您不需要删除 scope 选择器,但如果它已经在svelte.json文件中,则它是多余的,它将其中的所有片段限制为该文件类型。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM