javascript - Angular 显示表格中断页面
问题描述
我已经使用 angular 有一段时间了,花了一年的时间来做一些其他的事情,然后回来开发一个新网站,我正在开发一个似乎运行良好的网站,直到我尝试导入 mat-table 及其所有依赖项。
这是我拥有的主要组件的 .ts 代码
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import {MatTableModule} from '@angular/material/table';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
AppRoutingModule,
MatTableModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
一旦我删除了导入部分中的 MatTableModule 行。该页面再次像往常一样显示。
.ts 文件
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'my-app';
}
.html 文件
<!-- Toolbar -->
<div class="toolbar" role="banner">
<img
width="40"
alt="game logo"
src="https://gamepedia.cursecdn.com/valorant_esports_gamepedia_en/thumb/d/d9/Logo_square.png/123px-Logo_square.png?version=4e7ad8c9f85ac6ace6fa98cf2eecdbeb"
/>
<span>Valorant LFG</span>
<div class="spacer"></div>
<!--anything for the right side of toolbar-->
</div>
<div class="content" role="main">
<!-- Options -->
<h2>Create a valorant team of your own, allowing other playerrs to join you</h2>
<div class="card-container">
<a class="card" target="_blank" rel="noopener" href="https://angular.io/cli">
<img class="createteamicon" src="https://image.flaticon.com/icons/png/512/1189/1189206.png" alt="handshake" width="45" height="45">
<span>Create Team</span>
</a>
</div>
<div>
<h2>Current LFG Requests, resets after 24 hours</h2>
</div>
</div>
<router-outlet></router-outlet>
我确定我做了一些非常小的事情,但这是我的小问题 atm。
这是 chrome 上的控制台错误
https://gyazo.com/05a62301b4937a8669690f1c2168f32b
如果您对此有任何答案,将不胜感激,谢谢
解决方案
您可以参考以下教程,详细了解如何使用材料数据表模块。
推荐阅读
- python - 两个数据框的特定列的总和值
- jquery - 通过自动完成 jQuery 填写文本字段值?
- flutter - Flutter:如何隐藏 AlertDialog
- c++ - 在 C++ 代码中添加终端间隙分数以获得最佳序列比对分数
- angular - 将角度 6 升级到 9 的最佳方法是什么?
- ios - 运行带有结果的 Swift Playground 会导致运行时错误
- git - 在执行 git 操作时在 java 中保持干净的代码
- java - 具有全局变量的文本视图
- reactjs - Stripe - 接受付款引发集成错误
- ios - 属性“self.readCount”未在 super.init 调用中初始化