微软VS Code和Angular 2标签在HTML linter中 [英] Microsoft VS Code and Angular 2 tags in HTML linter

查看:325
本文介绍了微软VS Code和Angular 2标签在HTML linter中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始在VSCode中使用Angular 2。以Angular.io的Tour of Heroes为例,内置的HTML linter无法识别HTML标签中的Angular 2指令,如 * ng-if (点击),如下图所示:

//i.stack.imgur.com/Xflfq.pngrel =nofollow noreferrer>



是否有一些设置或扩展名我缺少?这是一个Angular 2应用程序中有效的HTML代码,我不需要很多错误 - 但是我想在其他地方发生实际错误时使用linter。

解决方案

您可以将例外添加到HTMLHint扩展中的属性列表中:

 htmlhint.options:{
attr-lowercase:[* ngIf,* ngFor]
}

attr-lowercase规则可以是true,false或一组要忽略的属性名称。


I just started using Angular 2 in VSCode. Using the Angular.io "Tour of Heroes" as an example, the built-in HTML linter does not recognize the Angular 2 directives in the HTML tags, such as *ng-if or (click), as you can see in this screen shot:

Is there some setting or extension I am missing? This is valid HTML code in an Angular 2 app and I don't want a lot of errors for nothing -- but I want to use the linter in case I make actual errors elsewhere.

解决方案

You can add exceptions to the list of attributes in the HTMLHint extension:

"htmlhint.options": {
    "attr-lowercase": ["*ngIf", "*ngFor"]
}

The attr-lowercase rule can be true, false or an array of attribute names to ignore.

这篇关于微软VS Code和Angular 2标签在HTML linter中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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