[*ngIf]的属性名称必须为小写

Sam*_*ath 14 visual-studio-code

你能告诉我如何在VS code编辑器上删除以下信息吗?

The attribute name of [ *ngIf ] must be in lowercase.
Run Code Online (Sandbox Code Playgroud)

以上信息显示在下面的代码上

 <div *ngIf="isBornOn">

 </div>
Run Code Online (Sandbox Code Playgroud)

Ste*_*son 38

我认为这与vscode-htmlhint插件有关,请尝试禁用它.

如果删除了警告,则可以通过设置attr-lowercase为false 来禁用该规则.

在此处阅读有关此插件配置的更多信息

在VSCode中,您可以设置以下设置以禁用它:

"htmlhint.options": {
  "attr-lowercase": false
}
Run Code Online (Sandbox Code Playgroud)

如果在使用不遵循小写规则的属性时不想丢失警告.您可以定义属性白名单,而不是:

"htmlhint.options": {
    "attr-lowercase": [
      "*ngIf",
      "ngIf",
      "*ngFor",
      "ngFor",
      "ngSwitch",
      "ngModel"
    ],
    "doctype-first": false
  },
Run Code Online (Sandbox Code Playgroud)

也可以添加doctype-first以避免每个组件上的消息.


dal*_*ale 5

任何想要从另一个IDE(例如Eclipse或Codemix)解决此问题的人,只需创建一个名为.htmlhintrcplace this 的文件,/<angular-project>/src/.htmlhintrc 然后根据需要更改值即可,我的是:

{
    "tagname-lowercase": false,
    "attr-lowercase": false,
    "attr-value-double-quotes": true,
    "doctype-first": false,
    "tag-pair": true,
    "spec-char-escape": true,
    "id-unique": true,
    "src-not-empty": true,
    "attr-no-duplication": true,
    "title-require": true
}
Run Code Online (Sandbox Code Playgroud)

如果无法自动解决,请重新打开该选项卡,然后重新启动IDE。