加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

Angular2 CUSTOM_ELEMENTS_SCHEMA不起作用

发布时间:2020-12-17 07:19:29 所属栏目:安全 来源:网络整理
导读:我刚刚使用ng2 cli安装了一个bearbones ng2 app.在我的AppModule中,我添加了模式:[CUSTOM_ELEMENTS_SCHEMA],在我的AppComponent模板中,我有 row / row.但我得到 – Unhandled Promise rejection: Template parse errors: ‘row’ is not a known element: 1
我刚刚使用ng2 cli安装了一个bearbones ng2 app.在我的AppModule中,我添加了模式:[CUSTOM_ELEMENTS_SCHEMA],在我的AppComponent模板中,我有< row>< / row>.但我得到 –

Unhandled Promise rejection: Template parse errors:
‘row’ is not a known element:
1. If ‘row’ is an Angular component,then verify that it is part of this module.
2. If ‘row’ is a Web Component then add “CUSTOM_ELEMENTS_SCHEMA” to the ‘@NgModule.schemas’ of this component to suppress this message. (“[ERROR ->]

AppModule-

import { BrowserModule } from '@angular/platform-browser';
import { NgModule,CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';

import { AppComponent } from './app.component';


@NgModule({
  declarations: [
    AppComponent
  ],imports: [
    BrowserModule,FormsModule,HttpModule
  ],providers: [],bootstrap: [AppComponent],schemas: [ CUSTOM_ELEMENTS_SCHEMA ]
})
export class AppModule { }

AppComponent-

import { Component } from '@angular/core';

@Component({
  selector: 'app-root',templateUrl: './app.component.html',styleUrls: ['./app.component.css']
})
export class AppComponent {}

AppComponentTemplate-

<row></row>

这真的很简单.到底他妈发生了什么?

编辑:

以下所有答案都令人满意,并提供了对问题的深入了解. @yurzui我特别喜欢你提供源代码的答案.我希望我能给你所有接受的答案!但我会选择@camaron作为第一个并直接解决我的问题.如果你通过谷歌找到这个问题,请给@yurzui,@camaron和@Aravind一个1来帮助解决这个问题!

您需要添加要由AppModule导入的RowComponent

导入:[RowComponent]

编辑:

使用NO_ERRORS_SCHEMA,这是因为angular正在尝试查找不存在的组件.

CUSTOM_ELEMENTS_SCHEMA用于选择器名称中带有 – 的组件.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读