gpt4 book ai didi

Angular 9 mat-card-actions' 不是已知元素

转载 作者:行者123 更新时间:2023-12-03 20:53:42 25 4
gpt4 key购买 nike

Angular 9 mat-card-actions' 不是已知元素,我已经导入和导出了 Angular Material 模块,但出现以下错误:

 mat-card-actions' is not a known element:
mat-grid-tile' is not a known element:

这是代码 app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { PostsComponent } from './content/components/posts/posts.component';
import { DefaultComponent } from './default/default.component';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import {MatSidenavModule} from '@angular/material/sidenav';
import {MatToolbarModule} from '@angular/material/toolbar';
import {MatIconModule} from '@angular/material/icon';
import {MatButtonModule} from '@angular/material/button';
import {MatListModule} from '@angular/material/list';
import {MatExpansionModule} from '@angular/material/expansion';
import {MatTooltipModule} from '@angular/material/tooltip';
import {MatGridListModule} from '@angular/material/grid-list';
import {MatMenuModule} from '@angular/material/menu';
import {MatCardModule} from '@angular/material/card';


import { RouterModule } from '@angular/router';

const mats=[
BrowserAnimationsModule,
MatSidenavModule,
MatToolbarModule,
MatIconModule,
MatButtonModule,
RouterModule,
MatListModule,
MatExpansionModule,
MatTooltipModule,
MatGridListModule,
MatMenuModule,
MatCardModule
]

@NgModule({
declarations: [
AppComponent,
PostsComponent,
DefaultComponent
],
imports: [
BrowserModule,
AppRoutingModule,
mats,
BrowserAnimationsModule
],
exports:[mats],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }

这是component.html代码:
 <mat-card class="example-card">
<mat-card-header>
<div mat-card-avatar class="example-header-image"></div>
<mat-card-title>Shiba Inu</mat-card-title>
<mat-card-subtitle>Dog Breed</mat-card-subtitle>
</mat-card-header>
<img mat-card-image src="https://material.angular.io/assets/img/examples/shiba2.jpg" alt="Photo of a Shiba Inu">
<mat-card-content>
<p>
The Shiba Inu is the smallest of the six original and distinct spitz breeds of dog from Japan.
A small, agile dog that copes very well with mountainous terrain, the Shiba Inu was originally
bred for hunting.
</p>
</mat-card-content>
<mat-card-actions>
<button mat-button>LIKE</button>
<button mat-button>SHARE</button>
</mat-card-actions>
</mat-card>

最佳答案

这些错误是新 Ivy 编译器的一部分

我通过转到 tsconfig 并设置 来修复它启用 Ivy 假的

"angularCompilerOptions": {
"fullTemplateTypeCheck": true,
"strictInjectionParameters": true,
"enableIvy":false
}

关于Angular 9 mat-card-actions' 不是已知元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61812703/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com