错误:"clr-icon"不是已知元素: [英] ERROR in : 'clr-icon' is not a known element:
问题描述
运行以下命令:
ng build --prod --base-href ./
我得到:
ERROR in : 'clr-icon' is not a known element:
1. If 'clr-icon' is an Angular component, then verify that it is part of this module.
2. If 'clr-icon' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("spinner spinner-sm spinner-inverse" [style.display]="loading ? 'inline-block' : 'none'"></span>
[ERROR ->]<clr-icon clrSignpostTrigger shape="check" size="20" class="is-info" [style.display]="!loading && req")
我使用的是Angular 7和Clarity 1.04.
I'm on Angular 7 and Clarity 1.04.
从我的 angular.json
中提取:
"styles": [
"node_modules/@clr/icons/clr-icons.min.css",
"node_modules/@clr/ui/clr-ui.min.css",
"node_modules/prismjs/themes/prism-solarizedlight.css",
"src/styles.css",
"node_modules/lato-font/css/lato-font.min.css"
],
"scripts": [
"node_modules/core-js/client/shim.min.js",
"node_modules/mutationobserver-shim/dist/mutationobserver.min.js",
"node_modules/@webcomponents/custom-elements/custom-elements.min.js",
"node_modules/web-animations-js/web-animations.min.js",
"node_modules/prismjs/prism.js",
"node_modules/prismjs/components/prism-typescript.min.js",
"node_modules/@clr/icons/clr-icons.min.js"
]
关于如何调试的任何想法?
Any ideas for how I can debug?
推荐答案
clr-icon
是一个自定义元素,但您可能知道这一点.
clr-icon
is a custom element but you probably know this.
您是否可以尝试将其添加到您的 polyfills.ts
文件中(如果使用AngularCLI工具生成的文件,它应该与 app/
目录处于同一级别.
Can you try adding this to your polyfills.ts
file ( it should be at the same level as the app/
directory if you generated with the AngularCLI tool.
import '@webcomponents/custom-elements';
import '@clr/icons';
然后,将 angular.json
文件中的scripts数组删除为空,然后查看是否可以生成.如果确实开始,则将其他脚本列入列出的脚本中(减去:"node_modules/@clr/icons/clr-icons.min.js"
和以下:"node_modules/@ webcomponents/custom-elements/custom-elements.min.js,
)一一确定,以确保它们不会引起任何问题.
Then, strip down the scripts array in your angular.json
file be empty and see if it builds. If it does start putting the other scripts listed scripts (minus this: "node_modules/@clr/icons/clr-icons.min.js"
and this: "node_modules/@webcomponents/custom-elements/custom-elements.min.js",
) one by one to make sure they aren't causing any issues.
这篇关于错误:"clr-icon"不是已知元素:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!