SASS 模板字符串。这是一种使用它们的方法吗?

SASS template strings. Is it a way to use them?

也许这是一个微不足道的问题,但我没有找到任何关于 sass 模板字符串的信息,因为在 less 语法中它有:

less: @media-screen-phone: ~'screen and (max-width: 540px)';

下一个用法:

// ...some *.less file

@media-screen-phone: {
  // ... some style rules
}

// ...

那么,是否可以像我上面显示的那样在 sass 中使用 less 中的这种方法?

谢谢。

LessCss波浪号(~)'function'只是一个帮手:

Notice that our CSS property value is quoted, which we don't want.

This is where the tilde comes into play. If you precede the quoted value with a tilde, the tokens will still be grouped into a single value, but the quotes will be stripped off.

That is all that the tilde does - strip quotes. It does nothing else. If you use tildes currently, you probably don't actually need them in half the cases. If you're anything like me, you [incorrectly] copy-pasted them from online demos without actually knowing what it was doing.

引用自用更少的语言思考字符串、引号、标记和波浪符 CSS 。强调与原文相同。

SCSS 的流行语是 string interpolation

也是一样的,只不过不是在定义的时候,而是在使用的时候。

// SCSS
$media-screen-phone: "screen and (max-width: 540px)";

@media #{$media-screen-phone} {
  body {
    color: red;
  }
}