VSCode 无法识别我包含在 svelte 文件中的 scss。它认为它们是 css 样式,并且它遇到的第一个嵌套 css 给了我错误。我尝试在设置中禁用 css 验证,但似乎没有任何效果: "css.validate": false, svelte 应用程序可以通过在本地启动或编译生产包来正常工作(这不是我的代码的问题)。这只是 VSCode 如何控制我的样式的问题。对于这个问题,我的大多数精简组件看起来都是错误的,即使它们实际上并非如此。为了编译像 scss 这样的样式,我将属性添加type="text/scss"到标签中:
<style type="text/scss">
Run Code Online (Sandbox Code Playgroud)
所有错误都有代码:“ css-syntax-error”。我认为原因是 VS Code 无法识别它是 SCSS 而不是 CSS。
我在 svelte 中有这些 sass 扩展:
我的 VSCode 设置:
{
"svelte.language-server.runtime": "......",
"scss.lint.important": "warning",
"editor.formatOnPaste": true,
"css.completion.triggerPropertyValueCompletion": false,
"css.completion.completePropertyWithSemicolon": false,
"css.lint.argumentsInColorFunction": "ignore",
"css.lint.hexColorLength": "ignore",
"css.lint.duplicateProperties": "warning",
"editor.suggestSelection": "first",
"vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
"workbench.colorTheme": "Material Theme Darker",
"css.validate": false,
"editor.codeActionsOnSave": {},
"git.enableSmartCommit": true, …Run Code Online (Sandbox Code Playgroud)