如何在sass中保留引用的字符

问题描述 投票:1回答:1

我怎样才能保存或逃脱sass中的路径。我们有像"Page\Footer\CustomBar\Logo"这样的字符串(错误地)在内部转换为"Page\footer\customBarLogo"我们如何保留ascii格式?我们试过用dart sass和ruby sass。

Page\Footer\CustomBar\Logo将是预期的结果。

sass node-sass gulp-ruby-sass
1个回答
0
投票

我搜索了一下,我没有找到任何内置的方法来做你需要的。看起来SCS难以操纵反斜杠。但是,这是我如何设法得到你的道路:

@function createPath($path...) {
   $finalPath: null;

   @each $el in $path {
      @if($finalPath) {
         // Do not add the slashes at the beginning of the string
         $finalPath: $finalPath + "\\";
      };

      $finalPath: $finalPath + $el;
   }

   // At this point, $finalPath = "Page\\Footer\\CustomBar\\Logo"
   @return unquote("\"#{$finalPath}\"");
}

打电话给createPath('Page', 'Footer', 'CustomBar', 'Logo');将返回"Page\Footer\CustomBar\Logo"

老实说,我无法解释unquote如何工作,我找到了解决方案感谢this answer

© www.soinside.com 2019 - 2024. All rights reserved.