less css,定义空字符串变量
我想定义一个变量,在某些情况下可能为空 @prefix: "";
并像这样使用它 src: url("@{prefix}/path/to/something");
问题是它编译成 src: url("""/path/to/something");
如何定义一个可以编译的空字符串变量 src: url("/path/to/something");
I want to define a variable, which could be empty in some cases@prefix: "";
and to use it like thissrc: url("@{prefix}/path/to/something");
the problem is that it compiles intosrc: url("""/path/to/something");
How to define an empty string variable, that can be compiled insrc: url("/path/to/something");
Update:
Issue closed
https://github.com/cloudhead/less.js/issues/532
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
刚刚找到了一种方法来做到这一点...转义空字符串
@prefix: ~'';
我使用经常保留的 box-shadow
inset
选项遇到了这个问题空的。Just found a way to do this... escape an empty string
@prefix: ~'';
I ran into this with the box-shadow
inset
option that will often remain empty.我不确定这是否可能在更少的时间内实现。您可以创建一个 mixin 函数,它返回带有前缀的路径。如果您想偶尔更改前缀并且只需在一个地方执行此操作,这将很有用。
I'm not sure this is possible in less. You could make a mixin function which returns the path with the prefix prepended to it. This would be useful if you want to change the prefix once in awhile and only have to do it in one place.