Sass:打印到终端 [英] Sass: print to terminal

查看:1158
本文介绍了Sass:打印到终端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法让Sass打印一个变量到终端?

Is there a way to have Sass print out a variable to the terminal?

推荐答案

Sass 3.3及更早版本



有两个与错误相关的指令:

Sass 3.3 and older

There are 2 error related directives:

@debug


@debug指令会将SassScript表达式的值标准错误输出流。

The @debug directive prints the value of a SassScript expression to the standard error output stream.



@debug 10em + 12em;

输出:

Line 1 DEBUG: 22em

@warn


@warn指令会输出值的SassScript表达式转换为标准错误输出流。这对于需要警告用户废弃或从小的mixin使用错误中恢复的库非常有用。

The @warn directive prints the value of a SassScript expression to the standard error output stream. It's useful for libraries that need to warn users of deprecations or recovering from minor mixin usage mistakes.



@warn 'This is a warning';



Sass 3.4及更新版本



@error


@error指令将SassScript表达式的值作为致命错误,包括一个很好的堆栈跟踪。它对于验证mixins和函数的参数很有用。例如:

The @error directive throws the value of a SassScript expression as a fatal error, including a nice stack trace. It’s useful for validating arguments to mixins and functions. For example:



@error 'This is an error';

.foo {
  background: red;
}

这篇关于Sass:打印到终端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆