弃用警告:在 calc() 之外使用 / 进行除法已被弃用,并将在 Dart Sass 2.0.0 中删除
在这些函数中,我将 rem
编译为 px
并将 em
编译为 px
:
$base: 16 !default;
@function scut-strip-unit ($num) {
@return $num / ($num * 0 + 1);
}
@function rem ($pixels) {
@return scut-strip-unit($pixels) / $base * 1rem;
}
@function em ($pixels, $context: $base) {
@return #{$pixels/$context}em;
}
但是使用 Sass v1.49
,我们面临这个错误:
Error
Deprecation Warning: Using / for division outside of calc() is deprecated and will be removed in
Dart Sass 2.0.0.
Recommendation: math.div(scut-strip-unit($pixels), $base) or calc(scut-strip-unit($pixels) / $base)
More info and automated migrator: https://sass-lang.com/d/slash-div
╷
8 │ @return scut-strip-unit($pixels) / $base * 1rem;
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
╵
Deprecation Warning: Using / for division outside of calc() is deprecated and will be removed in
Dart Sass 2.0.0.
Recommendation: math.div($pixels, $context) or calc($pixels / $context)
More info and automated migrator: https://sass-lang.com/d/slash-div
╷
11 │ @return #{$pixels/$context}em;
│ ^^^^^^^^^^^^^^^^
╵
In these functions I compile rem
to px
and em
to px
:
$base: 16 !default;
@function scut-strip-unit ($num) {
@return $num / ($num * 0 + 1);
}
@function rem ($pixels) {
@return scut-strip-unit($pixels) / $base * 1rem;
}
@function em ($pixels, $context: $base) {
@return #{$pixels/$context}em;
}
But with Sass v1.49
, we are facing this error:
Error
Deprecation Warning: Using / for division outside of calc() is deprecated and will be removed in
Dart Sass 2.0.0.
Recommendation: math.div(scut-strip-unit($pixels), $base) or calc(scut-strip-unit($pixels) / $base)
More info and automated migrator: https://sass-lang.com/d/slash-div
╷
8 │ @return scut-strip-unit($pixels) / $base * 1rem;
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
╵
Deprecation Warning: Using / for division outside of calc() is deprecated and will be removed in
Dart Sass 2.0.0.
Recommendation: math.div($pixels, $context) or calc($pixels / $context)
More info and automated migrator: https://sass-lang.com/d/slash-div
╷
11 │ @return #{$pixels/$context}em;
│ ^^^^^^^^^^^^^^^^
╵
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将不再支持使用
/
在calc
函数之外进行除法。以下是文档中的原因概述:您应该使用
sass:math
中的math.div
:或者在
calc
中使用/
:Using
/
to make divisions outside ofcalc
function will not be supported anymore. Here is an overview of the reasons why from the documentation:You should either use
math.div
fromsass:math
:Or use
/
insidecalc
:为了避免使用 sass:math,你可以使用
To avoid using sass:math, you may just use