Javascript evaluation error in LESS file

心已入冬 提交于 2019-12-12 03:27:14

问题


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}";
}

But I still get an error at variable @winheight:

LESS: JavaScript evaluation error: 'TypeError: 'document.documentElement.clientHeight' is null or not an object'

How to fix this? Where is my mistake ?


回答1:


document.documentElement.clientHeight can only exists when running less.js, in browser see: http://lesscss.org/usage/#using-less-in-the-browser.

In all other situations your Less code will be compiled into static CSS code.



来源:https://stackoverflow.com/questions/28023326/javascript-evaluation-error-in-less-file

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