AngularMaterial-编译错误-'mat-cell'不是已知元素:
创始人
2024-10-28 07:01:43
0
  1. 确保在你的 app.module.ts 导入了 MatIconModule,MatTableModule 和 BrowserAnimationsModule:

import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; import { AppComponent } from './app.component'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { MatIconModule } from '@angular/material/icon'; import { MatTableModule } from '@angular/material/table';

@NgModule({ declarations: [ AppComponent ], imports: [ BrowserModule, BrowserAnimationsModule, MatIconModule, MatTableModule ], providers: [], bootstrap: [AppComponent] }) export class AppModule { }

  1. 如果你在其他模块中使用了 MatTable,你需要在那些模块中导入 MatTableModule。

  2. 如果你的组件使用到 MatTable,确保在组件的 .ts 和 .html 文件中都正确引入了 MatTable:

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

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

displayedColumns: string[] = ['position', 'name', 'weight', 'symbol']; dataSource = ELEMENT_DATA;

}

No. {{element.position}} Name {{element.name}} Weight {{element.weight}} Symbol {{element.symbol}}

  1. 如果你对 Angular Material 不熟悉,建议先阅读官方文档:https://material.angular.io/。

相关内容

热门资讯

第2分钟辅助!wepoker私... 第2分钟辅助!wepoker私人局开挂视频,wepoker黑侠辅助器,策略教程(有挂神器)1、完成w...
七分钟辅助!wepoker免费... 七分钟辅助!wepoker免费脚本咨询,德普之星透视辅助软件下载,攻略教程(真是有挂)德普之星透视辅...
两分钟辅助!哈糖大菠萝挂,德普... 两分钟辅助!哈糖大菠萝挂,德普之星辅助工具如何打开,资料教程(有挂教程)1、两分钟辅助!哈糖大菠萝挂...
三分钟辅助!hhpoker辅助... 三分钟辅助!hhpoker辅助靠谱吗,hh poker透视器下载,窍要教程(详细教程)所有人都在同一...
第九分钟辅助!德普之星透视,w... 第九分钟辅助!德普之星透视,wpk透视辅助方法,指引教程(有挂秘诀)进入游戏-大厅左侧-新手福利-激...
6分钟辅助!拱趴大菠萝机器人,... 6分钟辅助!拱趴大菠萝机器人,wepoker养号规律,绝活儿教程(有挂头条)1、拱趴大菠萝机器人有没...
第4分钟辅助!wepoker透... 第4分钟辅助!wepoker透视方法,德州私人局脚本,举措教程(有挂头条)德州私人局脚本能透视中分为...
9分钟辅助!德普之星私人局辅助... 9分钟辅助!德普之星私人局辅助器,xpoker辅助神器,机巧教程(证实有挂)进入游戏-大厅左侧-新手...
第3分钟辅助!we poker... 第3分钟辅助!we poker辅助器v3.3,wepoker透视功能下载,机巧教程(有挂透视)1、超...
第8分钟辅助!wepoker怎... 第8分钟辅助!wepoker怎么开辅助,黑侠破解wepoker,课程教程(今日头条)1、上手简单,内...