我在使用ngx头像时遇到这些错误
未捕获的错误:模板解析错误:
'ngx-avatar' is not a known element:
1. If 'ngx-avatar' is an Angular component, then verify that it is part of this module.
2. If 'ngx-avatar' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
(“
[ERROR ->]<ngx-avatar name="John Doe"></ngx-avatar>
“):
ng:///CardDetailsModule/CardDetailsComponent.html@118:6
at syntaxError (compiler.js:2175)
at TemplateParser.parse (compiler.js:11388)
at JitCompiler._parseTemplate (compiler.js:25963)
at JitCompiler._compileTemplate (compiler.js:25951)
at compiler.js:25895
at Set.forEach (<anonymous>)
at JitCompiler._compileComponents (compiler.js:25895)
at compiler.js:25808
at Object.then (compiler.js:2166)
at JitCompiler._compileModuleAndComponents (compiler.js:25807)
我已将它们包含在app.module.ts中
import { AvatarModule } from 'ngx-avatar';
。。。
imports: [...,AvatarModule]
我已全局安装了ngx,但仍无法正常工作
我认为您的项目中有两个模块
ngx-avatar在属于CardDetails Module的cardsDetailComponent中使用。但是,您已导入app.module中的ngx头像。
尝试在cardDetails.module]中导入ngx-avatar模块并进行检查。假设您正在多个模块中使用ngx-avatar,则意味着将其移动到shared module并将其导入到需要的模块
一旦ngx头像导入到cardDetails.module,请确保将其从app.module
删除