【问题标题】:Visual Studio 2012 Web Essentials 3.7 LESS "variable ... is undefined"Visual Studio 2012 Web Essentials 3.7 LESS“变量......未定义”
【发布时间】:2014-03-03 15:29:47
【问题描述】:

我有 VS 2012 Premium Update 4 和最近发布的(2014 年 2 月 25 日)Web Essentials 3.7,用于编译 LESS 文件。

我正在通过将我自己的自定义 LESS 文件添加到编译过程中来自定义 (Twitter) Bootstrap 前端框架:

我有这个文件夹结构:

main-file.less
bootstrap/
    less/
        [all bootstrap .less files]
    custom/
        custom-mixins.less
        custom-other.less
        custom-variables.less

main-file.less 我有:

@import "bootstrap/less/bootstrap";
@import "bootstrap/custom/custom-variables";
@import "bootstrap/custom/custom-mixins";
@import "bootstrap/custom/custom-other";

我是否在导入指令中应用“.less”扩展名似乎没有区别。

在编译 main-files.less 时,我不断收到如下错误:

variable @my-label-color is undefined
variable @grid-gutter-width is undefined

对可能出现的问题有什么想法吗?

【问题讨论】:

    标签: visual-studio-2012 less web-essentials


    【解决方案1】:

    听起来导入顺序不正确。找出这些变量的定义位置,并确保在使用变量的文件之前导入该文件。

    更新

    正如seven-phases-max 正确指出的那样,变量可以在使用后定义。因此,您很可能在使用这两个变量时没有实际为它们赋值或定义它们。

    可能它们是在您尚未导入的 less 文件中定义的。检查这些变量的定义位置并确保它们位于main-files.less

    【讨论】:

    • 在定义之前可以使用较少的变量,因此错误不太可能与导入顺序有关。
    猜你喜欢
    • 2014-06-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-10
    • 1970-01-01
    相关资源
    最近更新 更多