loading

Using / for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0.

Scss/Sass 项目里使用 / 报错:Using / for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0.。指的是不能直接使用 / 来进行相除,已经在 Sass 2.0.0 版本被弃用。

不推荐降低版本,可能会失去一些好用的特性。如果你是 Vite 项目,可以按照以下步骤来:

引入 sass:math:

file:[vite.config.ts]
// css 预处理
css: {
  preprocessorOptions: {
    scss: {
      additionalData: `@use "sass:math";`
    }
  }
}

把 / 的地方改成 math.div(1, 1)

file:[src/components/Test.vue]
.example {
  top: $show-top + $i * math.div(($close-end - $show-top), 10);
}

也可以使用 calc 来代替 math.div/ 斜杠。网上也有说安装 sass-migrator 对 node_modules 进行配置的,我已经试验过了,没有任何效果。这是 Sass 官方对该问题的解释:Breaking Change: Slash as Division

posted @ 2023-02-16 22:06  Himmelbleu  阅读(34)  评论(0编辑  收藏  举报