【发布时间】:2019-02-05 19:10:25
【问题描述】:
如何在路径字符串中导入带有字符串插值的 .less 文件。
@folder: "LessFiles";
我试过了
@import "@{folder}/file.less";
Error:
File Not Found.
HTTP GET Url is "%7Bfolder%7D/file.less"
还有这个:
@import formatString("{0}/file.less",@folder);
Error:
Server throws System.NullReferenceException
还有这个:
@path: "@{folder}/file.less";
@import @path;
Error:
directive block with unrecognised format on line 16 in file 'test.less':
[15]:
[16]: @import @path;
--------^
[17]:
任何提示如何解决这个问题?
谢谢!
【问题讨论】:
-
这是 less.js 和 dotless 中即将推出的功能,但需要大量工作才能实现。
-
真的吗?但它非常适用于 css 属性,例如可以定义 [background-image: url('@{image-folder}/loading-image.gif');],我想知道困难的部分是什么。
-
导入是在解析和评估时完成的。需要在评估期间允许解析。
-
github 上的问题(感谢 Luke 的工作):github.com/dotless/dotless/issues/249
标签: string import less string-interpolation dotless