简体   繁体   English

live Sass 编译不编译列表操作

[英]Live Sass compiler does not compile list operations

I have an issue with the Live Sass compiler in VS Code, namely when working with lists.我在 VS Code 中遇到 Live Sass 编译器的问题,即在处理列表时。 None of the usual operations work.通常的操作都不起作用。 In the following example, it's list.nth(list,index) .在以下示例中,它是list.nth(list,index)

The following works fine in a Codepen :以下在Codepen中工作正常:

HTML HTML

<p>red</p>
<p>blue</p>
<p>green</p>

SCSS SCSS

@use "sass:list";

p {
  font-size: 25x;
  font-weight: bold;
}

$colors: red blue green;

@for $n from 1 through 3 {
   p:nth-child(#{$n}) {
      color: list.nth($colors,$n);
   }  
 }

This also works fine when compiling it locally with the Dart Sass CLI.这在使用 Dart Sass CLI 在本地编译时也能正常工作。

But when I try to compile this with the Live Sass compiler in VS Code, I get the following error:但是当我尝试在 VS Code 中使用 Live Sass 编译器编译它时,出现以下错误:

Compilation Error
Error: Invalid CSS after "...    color: list": expected expression (e.g. 1px, bold), was ".nth($colors, $n);"

Why is that?这是为什么?

Use Live Sass Compiler by Glenn Marks使用 Glenn Marks 的 Live Sass 编译器


I had exactly the same problem.我有完全相同的问题。 You read the SASS official website, follow the instructions, write the code in Visual Studio Code, and then you get this strange Compilation Error when saving the SASS or SCSS file.你看了SASS官网,按照说明,在Visual Studio Code中写代码,结果在保存SASS或者SCSS文件的时候出现了这个奇怪的Compilation Error You double-check everything and it seems like it should work, but it doesn't.您仔细检查了所有内容,看起来它应该可以工作,但事实并非如此。

Well, the problem is caused by the Visual Studio Code extension you are using for compiling SASS or SCSS files to CSS files.那么,问题是由您用于将 SASS 或 SCSS 文件编译为 CSS 文件的 Visual Studio Code 扩展引起的。


Don't use this extension: Live Sass Compiler by Ritwick Dey不要使用此扩展:Ritwick Dey 的 Live Sass Compiler

You are probably using this extension: Live Sass Compiler by Ritwick Dey.您可能正在使用扩展程序:Ritwick Dey 的 Live Sass Compiler。 It's widely used, but is no longer supported by the author.它被广泛使用,但作者不再支持它。 Consequently, the SASS version isn't updated.因此,SASS 版本不会更新。 This extension produces the error you are describing.此扩展会产生您所描述的错误。

Use this extension: Live Sass Compiler by Glenn Marks使用此扩展:Glenn Marks 的 Live Sass 编译器

You should use this extension: Live Sass Compiler by Glenn Marks.您应该使用扩展:Glenn Marks 的 Live Sass Compiler。 As the author states: A big thank you to @ritwickdey for all his work.正如作者所说:非常感谢@ritwickdey 所做的所有工作。 However, as they are no longer maintaining the original work, I have released my own which has been built upon it.但是,由于他们不再维护原始作品,因此我发布了我自己的作品,并以此为基础。 This extension compiles your SASS or SCSS files to CSS files successfully.此扩展将您的 SASS 或 SCSS 文件成功编译为 CSS 文件。

The extension you are using does not seem to be maintained anymore , you can try to use this one instead.您正在使用的扩展似乎不再维护,您可以尝试使用这个

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

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