LESS文件中的Javascript评估错误 [英] Javascript evaluation error in LESS file
问题描述
我在较少的文件中包含以下代码:
I have the follwoing code in less file:
@winheight: unit(`document.documentElement.clientHeight`, px);
我想在以下位置调用该变量:
and I want to call that variable in:
.test {
height: ~"@{winheight}";
}
但是在变量@winheight
上我仍然出现错误:
But I still get an error at variable @winheight
:
少:JavaScript评估错误:'TypeError: 'document.documentElement.clientHeight'为null或不是对象'
LESS: JavaScript evaluation error: 'TypeError: 'document.documentElement.clientHeight' is null or not an object'
如何解决此问题?我的错误在哪里?
How to fix this? Where is my mistake ?
推荐答案
document.documentElement.clientHeight
仅在运行less.js时存在,在浏览器中请参见:
document.documentElement.clientHeight
can only exists when running less.js, in browser see: http://lesscss.org/usage/#using-less-in-the-browser.
在所有其他情况下,您的Less代码将被编译为静态 CSS代码.
In all other situations your Less code will be compiled into static CSS code.
这篇关于LESS文件中的Javascript评估错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!