本文介绍了覆盖LESS变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下堆栈:

  1. Symfony2
  2. 安装了lessphp过滤器的树枝.
  3. Twitter Boostrap

在base.css中,我有:

In base.css i have:

// base.less
@import '/path/to/bootstrap.less'
@linkColor: 13px;

变量名根本不重要.它可以是引导程序中使用的任何其他变量.它只是不会被覆盖.但是,如果我将变量放入单独的.less文件中,然后将其导入base.less中,那么一切都会按预期进行:

Variable name is not important at all. It can be any other variable used in bootstrap. It just doesn't get overridden. But if i put the variable into separate .less file and import it in base.less everything works as expected:

// base.less
@import '/path/to/bootstrap.less'
@import '/path/to/variables.less'

// variables.less
@linkColor: 13px;

为什么这行得通,而另一个却行不通?查找了文档(less/lessphp),但找不到与此相关的任何内容. (或者我不知道在哪里看.)

Why does this work and the other not? Looked up for the docs (less/lessphp) but couldn't find anything related to this. (or i didn't know where to look).

有人可以解释为什么会这样吗?

Can someone explain why is this happening?

推荐答案

似乎是lessphp编译器中的错误.看看 github问题.您的变通方法是将变量声明放入另一个文件中,然后将其导入,就可以了.顺便谢谢;)

It looks like it's a bug in the lessphp compiler. Take a look at the github issue. Your workaround, to put the variable declaration into another file and also import it works just fine. Thanks by the way ;)

这篇关于覆盖LESS变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 10:06