typescript vscode伪错误:“fa-icon”不是已知元素

hgb9j2n6  于 2023-02-14  发布在  TypeScript
关注(0)|答案(2)|浏览(214)

我有一个问题与vscode,我得到一个错误:

'fa-icon' is not a known element:
1. If 'fa-icon' is an Angular component, then verify that it is part of this module.
2. If 'fa-icon' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.ng

但我已经将其导入到模块"app.module"中,并且此组件(称为"base")是根模块的一部分。
此问题仅出现在vscode中,并且应用程序正在运行,没有任何错误。

    • 密码:**

base.component.ts:

import { Component } from '@angular/core';
import { faFacebook, faInstagram, faTelegram } from '@fortawesome/free-brands-svg-icons';

@Component({
  selector: 'app-base',
  templateUrl: './base.component.html',
  styleUrls: ['./base.component.scss']
})
export class BaseComponent {

  facebook = faFacebook;
  instagram = faInstagram;
  telegram = faTelegram;

}

base.component.html:

<nav class="navbar navbar-dark bg-dark">
  <div class="container">
    <a class="navbar-brand">
      Quiz App
    </a>
    <div class="text-light float-end fs-5">
      <a href="#"><fa-icon class="text-light p-1" [icon]="facebook"></fa-icon></a>
      <a href="#"><fa-icon class="text-light p-1" [icon]="instagram"></fa-icon></a>
      <a href="#"><fa-icon class="text-light p-1" [icon]="telegram"></fa-icon></a>
    </div>
  </div>
</nav>
<div class="container">
  <router-outlet></router-outlet>
</div>

app.module.ts:

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { BaseComponent } from './base/base.component';
import { EffectsModule } from '@ngrx/effects';
import { StoreModule } from '@ngrx/store';
import { HomeComponent } from './views/home/home.component';
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';

@NgModule({
  declarations: [
    AppComponent,
    BaseComponent,
    HomeComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    BrowserAnimationsModule,
    StoreModule.forRoot({}),
    EffectsModule.forRoot([]),
    FontAwesomeModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }
ykejflvf

ykejflvf1#

加这个怎么样?

import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
j13ufse2

j13ufse22#

重新启动VS代码后,这些错误消失了。

相关问题