LESS文件中的Javascript评估错误 [英] Javascript evaluation error in LESS file

查看:143
本文介绍了LESS文件中的Javascript评估错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在较少的文件中包含以下代码:

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆