【发布时间】:2015-03-27 01:36:36
【问题描述】:
如果我要从同一个目录导入多个文件,我想重用目录路径(假设带有 import 语句的文件与导入目标不在同一目录中)。到目前为止,我已经尝试过:
@directoryPath: "../modules/core/less/";
@import @directoryPath + "file.less";
@import (@directoryPath + "file.less");
@import @{directoryPath}"file.less";
@import "@{directoryPath}file.less";
@filePath: @directoryPath + "file.less"; //I have verified this produces the proper string
@import @filePath;
@import @{filePath};
这 6 个 import 语句都不起作用。他们中的一些人在
source: url(/*LESS variables*/);
声明,但在@import 语句中的工作方式不同。有什么想法可行吗?
【问题讨论】:
-
是否可以让 grunt 在运行 lessc 命令之前插入文件名?
-
这个
@import "@{directoryPath}file.less";其实是对的。但看起来您正在使用lessphp(因为在标准中,@directoryPath + "file.less";是无效语句)并且它根本不支持导入的字符串插值。 -
我相信你列出的两个陈述都有错误,但我会再次检查。
-
您的第一条语句奏效了。如果你把它变成一个答案,我会把它标记为正确的。