本文介绍了使用LESS @import的未声明的变量.是什么原因造成的?有解决办法吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个LESS文件. Globals.less和Site.less. Globals.less包含我所有的全局变量(通用变量)和对CSS重置定义的导入. Site.less包含正在使用的样式.

I have 2 LESS files. Globals.less and Site.less. Globals.less contains all of my global (go figure) variables and an import to a CSS reset definition. Site.less contains the styles in use.

Globals.less:

Globals.less:

//Imports
@import "CSSReset.less";

//Colors
@color-background: rgb(0, 0 , 0);

站点少:

@import "Globals.less";

body {
    background: @color-background url('/Images/BackgroundTextureBody.png');
}

问题是这样的:在Visual Studio中,Site.less中的@ color-background带有下划线,并且错误是未声明的变量",但是LESS可以很好地编译为CSS,并且背景色正确设置为#000.这比什么都更令人烦恼,但是我丢失了Intellisense,并且在错误列表中得到了警告.我希望编辑器能够按预期方式运行,并且在我编辑Site.less时能够在Globals.less中看到"我的声明.我是在做错什么,这是错误还是我的环境设置不正确?

The problem is this: In Visual Studio @color-background in Site.less is underlined and the error is "Undeclared variable", but the LESS compiles to CSS just fine and the background color is properly set to #000. It is more of an annoyance than anything, but I lose Intellisense and I get warnings in my error list. I would like the editor to act as expected and be able to "see" my declarations in Globals.less when I am editing Site.less. Am I doing something wrong, is this a bug, or is my environment not setup correctly?

推荐答案

事实证明,我使用的是Web Essentials 2012的较旧版本.我应该检查并做的第一件事就是确保我的环境是最新.将Web Essentials更新到最新版本可解决此问题.

It turns out that I was using an older version of Web Essentials 2012. The first thing I should have checked and failed to do was to ensure that my environment was up to date. Updating Web Essentials to the latest version corrected the issue.

这篇关于使用LESS @import的未声明的变量.是什么原因造成的?有解决办法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 05:04