简体   繁体   English

Angular 显示分表页

[英]Angular shows table breaks page

Ive been using angular for a while took a year break to do some other stuff, then coming back to develop a new website i was developing a website which seemed to be working fine, until i tried importing the mat-table and all its dependencies.我一直在使用 angular 花了一年的时间做一些其他的事情,然后回来开发一个新网站,我正在开发一个似乎工作正常的网站,直到我尝试导入 mat-table 及其所有依赖项。

here is my.ts code for the maincomponent i have这是我拥有的主要组件的 my.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 { }

as soon as i remove the MatTableModule line in the imports part.一旦我删除了导入部分中的 MatTableModule 行。 the page shows back as usual again.该页面再次像往常一样显示。

.ts file .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 file .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>

im sure ive done something very small but this is my small issue atm.我确定我做了一些非常小的事情,但这是我的小问题 atm。

this is the console error on chrome这是 chrome 上的控制台错误

https://gyazo.com/05a62301b4937a8669690f1c2168f32b https://gyazo.com/05a62301b4937a8669690f1c2168f32b

if you have any answers to this it would be greatly appreciated, thanks如果您对此有任何答案,将不胜感激,谢谢

You could refer to the following tutorial for a detailed explanation of how to use the Material Data-Table Module.您可以参考以下教程,详细了解如何使用材料数据表模块。

https://www.techiediaries.com/angular-material-table/ https://www.techiediaries.com/angular-material-table/

add angular material to ur project将 angular 材料添加到您的项目

ng add @angular/material 
npm i 
ng serve 

I still dont know what i did, but i made a new project and installed the materials and imported tables again and it worked this time so i just copied the files over to that one and it works我仍然不知道我做了什么,但我做了一个新项目并再次安装了材料和导入的表格,这次它工作了,所以我只是将文件复制到那个,它工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM