当我尝试在我的angular 7应用程序中使用@fortawesome/angular-fontawesome时,我遇到了以下错误:
node_modules/@fortawesome/angular-fontawesome/angular-fontawesome"' has no exported member 'FaIconLibrary我按照文档中的说明对模块进行了如下初始化:
import { FontAwesomeModule, FaIconLibrary } from '@fortawesome/angular-fontawesome';
(...)
@NgModule({
declarations: [
AppComponent
],
imports: [
(...)
FontAwesomeModule,
(...)
],
bootstrap: [AppComponent]
})
export class AppModule {
constructor(library: FaIconLibrary) {
library.add(...icons);
}
}下面是我使用的确切版本:
"@angular/core": "7.2.2",
(...)
"@fortawesome/angular-fontawesome": "^0.3.0",
"@fortawesome/fontawesome-pro": "^5.11.2",
"@fortawesome/fontawesome-svg-core": "1.2.21",
"@fortawesome/free-brands-svg-icons": "5.10.1",
"@fortawesome/free-regular-svg-icons": "5.10.1",
"@fortawesome/free-solid-svg-icons": "5.10.1",非常感谢你的帮助!蒂埃里
发布于 2019-10-14 15:01:17
如果您看到release notes,则说明FaIconLibrary是从与angular 7.2.2不兼容的0.5.0版本添加的。然后你应该使用旧的方式来添加图标,例如:
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
import { library } from '@fortawesome/fontawesome-svg-core';
import { faSquare, faCheckSquare } from '@fortawesome/free-solid-svg-icons';
import { faSquare as farSquare, faCheckSquare as farCheckSquare } from '@fortawesome/free-regular-svg-icons';
import { faStackOverflow, faGithub, faMedium } from '@fortawesome/free-brands-svg-icons';
...
export class AppModule {
constructor() {
library.add(faSquare, faCheckSquare, farSquare, farCheckSquare, faStackOverflow, faGithub, faMedium);
}
}https://stackoverflow.com/questions/58371193
复制相似问题