less, producing the wrong output

若如初见. 提交于 2020-01-05 04:24:10

问题


Main file

@import (reference)  './kendo1.less';

.FadedGrid
{
    @import (reference)  './kendo2.less';
}

.FadedGrid
{
    @import (reference)  './kendo2.less';

    .k-grid-header th
    {
        background-color: @input-background-color;
    }
}

kendo1.less

@input-background-color: #000;

kendo2.less

@input-background-color: #fff;

This produces

.FadedGrid .k-grid-header th {
  background-color: #000000;
}

But the colour here should be #ffffff, not #000000


回答1:


You need to change you import from reference to multiple. If you set it to reference it seems to ignore the duplicate imports of the same file.

Import options: http://lesscss.org/features/#import-options

Example:

@import (reference)  './kendo1.less';

.FadedGrid
{
  @import (multiple)  './kendo2.less';
}

.FadedGrid
{
      @import (multiple)  './kendo2.less';

  .k-grid-header th
  {
    background-color: @input-background-color;
  }
}

Output:

/* Generated by less 2.4.0 */
.FadedGrid .k-grid-header th {
  background-color: #ffffff;
}


来源:https://stackoverflow.com/questions/29429459/less-producing-the-wrong-output

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!