事实证明,它实际上不是在‘reset.less’上失败,而是在‘bootstrap.less’上失败的,后者的第一行是一个导入语句“reset.less”。在循环中实现路径解析器解决了该问题。 // let them throw exceptions on casting because they should never be null.
var importer = (Importer)lessParser.Importer;
var filereader = (FileReader)importer.FileReader;
// "As" casting here ensures if the path resolver is another type that we cannot cast
// (ex. RelativePathResolver) that we get a null rather than an exception.
var pathresolver = filereader.PathResolver as ImportedFilePathResolver;
if (pathresolver != null)
pathresolver.CurrentFilePath = currentFilePath;
else
filereader.PathResolver = new ImportedFilePathResolver(currentFilePath); ... 展开详请