实时SASS编译器不编译列表操作

发布于 2025-01-20 15:50:16 字数 965 浏览 1 评论 0原文

我对 VS Code 中的 Live Sass 编译器 存在问题,即使用列表时。通常的操作都不起作用。在以下示例中,它是 list.nth(list,index)

以下内容在 Codepen 中工作正常:

HTML

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

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);
   }  
 }

当使用 Dart Sass CLI 进行本地编译时,这也可以正常工作。

但是,当我尝试在 VS Code 中使用 Live Sass 编译器对其进行编译时,出现以下错误:

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

这是为什么?

I have an issue with the Live Sass compiler in VS Code, namely when working with lists. None of the usual operations work. In the following example, it's list.nth(list,index).

The following works fine in a Codepen:

HTML

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

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.

But when I try to compile this with the Live Sass compiler in VS Code, I get the following error:

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

Why is that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

没有心的人 2025-01-27 15:50:17

使用Glenn Marks的Live Sass编译器

我遇到的问题完全相同。您可以阅读SASS官方网站,按照说明,在Visual Studio代码中编写代码,然后在保存SASS或SCSS文件时会收到此奇怪的编译错误。您会仔细检查所有内容,并且似乎应该有效,但事实并非如此。

,问题是由您使用的Visual Studio代码扩展程序引起

好吧 a href =“ https://marketplace.visualstudio.com/items?itemname=ritwickdey.live-sass” rel =“ nofollow noreferrer”> this 扩展:Ritwick Dey的Live Sass Compiler。它已被广泛使用,但不再得到作者的支持。因此,没有更新SASS版本。此扩展程序会产生您所描述的错误。

使用此扩展名:Glenn标记的Live Sass编译器

您应该使用扩展:Glenn Marks的Live Sass编译器。正如作者所说:非常感谢@ritwickdey的所有工作。但是,由于它们不再维护原始作品,因此我发布了自己的构建的。此扩展程序将您的SASS或SCSS文件汇编为CSS文件。

Use Live Sass Compiler by Glenn Marks

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. 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.

Don't use this extension: Live Sass Compiler by Ritwick Dey

You are probably using this extension: Live Sass Compiler by Ritwick Dey. It's widely used, but is no longer supported by the author. Consequently, the SASS version isn't updated. This extension produces the error you are describing.

Use this extension: Live Sass Compiler by Glenn Marks

You should use this extension: Live Sass Compiler by Glenn Marks. As the author states: A big thank you to @ritwickdey for all his work. 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.

九公里浅绿 2025-01-27 15:50:17

您使用的扩展似乎不再维护 ,您可以尝试使用 这个一个代替。

The extension you are using does not seem to be maintained anymore, you can try to use this one instead.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文