简体   繁体   English

如何在Visual Studio 2015中的LESS文件中获取Intellisense

[英]How to get Intellisense in LESS files in Visual Studio 2015

I recently moved my CSS structure to LESS and it's great, I really see many benefits from using LESS compared to plain CSS. 我最近将我的CSS结构移到了LESS,这很棒,我真的看到与普通CSS相比,使用LESS有很多好处。

The only issue I had so far is with Visual Studio 2015, because my LESS code is distributed into different files and folders I always get a Intellisense error like " Undeclared mixin " or " Undeclared variable ". 到目前为止,我唯一遇到的问题是Visual Studio 2015,因为我的LESS代码分布在不同的文件和文件夹中,所以我总是会遇到Intellisense错误,例如“ Undeclared mixin ”或“ Undeclared variable ”。

智能感知错误

This simply happens because my mixins, variables and other pieces of code are in different files and there's no automatic way for VS to know where they are. 发生这种情况仅仅是因为我的mixin,变量和其他代码在不同的文件中,并且VS没有自动的方法来知道它们在哪里。

Does anyone know how to solve this? 有谁知道如何解决这个问题?

尝试在使用变量的文件中添加“ @import(引用)...”。

@import (reference) "FileWithVariables.less";

First and foremost, have you installed the Web Essentials LESS extension? 首先,您是否已安装Web Essentials LESS扩展?

On second thoughts , just fit a reference comment on top of your document like so: 再三考虑,只需在文档顶部添加参考注释即可,如下所示:

/// <reference path="variables.less" />

Where the path="" will be the exact path to your file. 其中path=""将是文件的确切路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM