javascript - 尽管导入了模块并包含 CUSTOM_ELEMENTS_SCHEMA 模式,但组件不是已知元素
问题描述
PinchZoom 是ngx-pinch-zoom
我在 Angular 6 项目中安装的一个节点模块。值得注意的是,它也是一个 ionic 4 项目。
在我的 app.module.ts 中,我已导入PinchZoomModule
并包含CUSTOM_ELEMENTS_SCHEMA
在我的架构中。
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module';
import { PinchZoomModule } from 'ngx-pinch-zoom';
@NgModule({
declarations: [
AppComponent
],
schemas: [ CUSTOM_ELEMENTS_SCHEMA ],
entryComponents: [],
exports: [],
imports: [
BrowserModule,
AppRoutingModule,
PinchZoomModule,
],
providers: [],
bootstrap: [AppComponent],
})
export class AppModule {}
在一个页面中,我添加了正确的代码来使用 PinchZoom 功能:
<pinch-zoom>
<img class="question-image" [src]="myImageUrl" />
</pinch-zoom>
但是,当我运行我的应用程序时,出现以下错误:
'pinch-zoom' is not a known element:
1. If 'pinch-zoom' is an Angular component, then verify that it is part of this module.
2. If 'pinch-zoom' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("ss="ion-padding no-bottom-padding">
[ERROR ->]<pinch-zoom>
解决方案
您当前使用的是哪个组件 pinch-zoom ?
如果要导入PinchZoomModule
,则必须将使用该标签的组件也导入到导入的模块中PinchZoomModule
如果您在<pinch-zoom>
多个模块中使用标签,请考虑将其移至导入的一个共享模块PinchZoomModule
推荐阅读
- vba - 如何绕过使用 Excel VBA 回复邮件时生成错误的 Outlook 项目?
- java - Firestore 需要双嵌套表
- django - django runserver 不显示启动开发服务器消息
- vuejs2 - How to run a function with a delay from inside axios then
- java - 爪哇。无法从导入 java.security.Signature 导入 SHA256withRSA 签名
- leaflet - 无法让 dashArray 在 Leaflet 1.0.3 中的画布上工作
- redis - 如何获取 Redis 中键集的大小(以字节为单位)?
- java - 无法将 Premium_Fragment 转换为 Activity
- wso2 - WSO2IS-5.3.0 的 OIDC SSO 中缺少声明
- javascript - 如果已经激活 JS,则停止切换