模板解析错误:'md-grid-tile' 不是已知元素
Template parse errors: 'md-grid-tile' is not a known element
我在新的 Angular 中使用 Material 设计 2. 我将其连接到 app.module,如下所示:
import {MdButtonModule, MdCheckboxModule} from '@angular/material';
import {MdGridListModule, MdCardModule} from '@angular/material';
@NgModule({
imports: [
MdButtonModule,
MdCheckboxModule,
MdGridListModule,
MdCardModule
],
加载页面时,控制台出现错误:
VM1967 vendor.bundle.js:63286 Uncaught Error: Template parse errors:
'md-grid-tile' is not a known element:
1. If 'md-grid-tile' is an Angular component, then verify that it is part of this module.
2. If 'md-grid-tile' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("
<md-grid-list cols="7" rowHeight="2" id="weekly_schedule">
如何解决?我尝试了各种方法。
完整文件已连接material(现在它不会给出任何错误,但页面在浏览器中无限加载)
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { TranslateModule } from '@ngx-translate/core';
import { CoreModule } from '../core/core.module';
import { SharedModule } from '../shared/shared.module';
import { HomeRoutingModule } from './home-routing.module';
import { HomeComponent } from './home.component';
import { QuoteService } from './quote.service';
import { BrowserModule } from '@angular/platform-browser';
import {MdButtonModule, MdCheckboxModule} from '@angular/material';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import {MdGridListModule, MdCardModule} from '@angular/material';
@NgModule({
imports: [
BrowserAnimationsModule,
BrowserModule,
CommonModule,
TranslateModule,
CoreModule,
SharedModule,
HomeRoutingModule,
MdGridListModule
],
declarations: [
HomeComponent
],
providers: [
QuoteService
]
})
export class HomeModule { }
MaterialModule 已从 2.0.beta-11 中删除,如 changelog 中所示,
所以你必须使用 mat 而不是 md。但变化仍在继续,因此您需要在 git hub
上进行跟踪
将MGridListModule替换为MatGridListModule,也做import as import {MatGridListModule } from '@angular/material';
你会很高兴的..
我在新的 Angular 中使用 Material 设计 2. 我将其连接到 app.module,如下所示:
import {MdButtonModule, MdCheckboxModule} from '@angular/material';
import {MdGridListModule, MdCardModule} from '@angular/material';
@NgModule({
imports: [
MdButtonModule,
MdCheckboxModule,
MdGridListModule,
MdCardModule
],
加载页面时,控制台出现错误:
VM1967 vendor.bundle.js:63286 Uncaught Error: Template parse errors:
'md-grid-tile' is not a known element:
1. If 'md-grid-tile' is an Angular component, then verify that it is part of this module.
2. If 'md-grid-tile' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("
<md-grid-list cols="7" rowHeight="2" id="weekly_schedule">
如何解决?我尝试了各种方法。
完整文件已连接material(现在它不会给出任何错误,但页面在浏览器中无限加载)
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { TranslateModule } from '@ngx-translate/core';
import { CoreModule } from '../core/core.module';
import { SharedModule } from '../shared/shared.module';
import { HomeRoutingModule } from './home-routing.module';
import { HomeComponent } from './home.component';
import { QuoteService } from './quote.service';
import { BrowserModule } from '@angular/platform-browser';
import {MdButtonModule, MdCheckboxModule} from '@angular/material';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import {MdGridListModule, MdCardModule} from '@angular/material';
@NgModule({
imports: [
BrowserAnimationsModule,
BrowserModule,
CommonModule,
TranslateModule,
CoreModule,
SharedModule,
HomeRoutingModule,
MdGridListModule
],
declarations: [
HomeComponent
],
providers: [
QuoteService
]
})
export class HomeModule { }
MaterialModule 已从 2.0.beta-11 中删除,如 changelog 中所示, 所以你必须使用 mat 而不是 md。但变化仍在继续,因此您需要在 git hub
上进行跟踪将MGridListModule替换为MatGridListModule,也做import as import {MatGridListModule } from '@angular/material';
你会很高兴的..