我怎样才能保存或逃脱sass中的路径。我们有像"Page\Footer\CustomBar\Logo"
这样的字符串(错误地)在内部转换为"Page\footer\customBarLogo"
我们如何保留ascii格式?我们试过用dart sass和ruby sass。
Page\Footer\CustomBar\Logo
将是预期的结果。
我搜索了一下,我没有找到任何内置的方法来做你需要的。看起来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。