我只是想导入https://shoelace.style/库,以便在Angular应用程序中使用。
我已经尝试了他们推荐的将style和link元素添加到索引文件中的方法,我还尝试了添加他们的NPM包,然后将以下内容添加到我的angular.json中
"styles": [
"src/styles.scss",
"node_modules/@shoelace-style/shoelace/dist/themes/base.css"
],
"scripts": [
"node_modules/@shoelace-style/shoelace/dist/shoelace.js"
],然而,无论我做什么,只要我尝试使用特定的鞋带组件,比如<sl-button>,我就会得到'sl-button' is not a known element
我需要做些什么才能让它正常工作?
发布于 2021-03-21 00:35:04
尝试将此代码添加到应用程序模块架构中: CUSTOM_ELEMENTS_SCHEMA
发布于 2021-03-21 00:38:15
只需确保应用自定义元素模式,如下所示。
import { BrowserModule } from '@angular/platform-browser';
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { AppComponent } from './app.component';
@NgModule({
declarations: [AppComponent],
imports: [BrowserModule],
providers: [],
bootstrap: [AppComponent],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
export class AppModule {}您可以找到有关CUSTOM_ELEMENTS_SCHEMA here的更多信息
https://stackoverflow.com/questions/66723808
复制相似问题