我在试着在组件里用垫片。在升级到角15之前,我的代码就可以工作了。
我正在导入模块,这似乎是一个常见的错误。
我想我已经按照医生的要求把所有的东西都包括了。
非常感谢提供的援助。谢谢
错误是:
Error: src/app/app.component.html:1:1 - error NG8001: 'mat-chip-list' is not a known element:
1. If 'mat-chip-list' is an Angular component, then verify that it is part of this module.
2. If 'mat-chip-list' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
1 <mat-chip-list>
~~~~~~~~~~~~~~~
src/app/app.component.ts:5:16
5 templateUrl: './app.component.html',
~~~~~~~~~~~~~~~~~~~~~~
Error occurs in the template of component AppComponent.
版本信息是:
Angular CLI: 15.0.0-rc.3
Node: 16.14.0
Package Manager: npm 9.1.1
OS: linux x64
Angular: 15.0.0-rc.3
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1500.0-rc.3
@angular-devkit/build-angular 15.0.0-rc.3
@angular-devkit/core 15.0.0-rc.3
@angular-devkit/schematics 15.0.0-rc.3
@angular/cdk 15.0.0-rc.2
@angular/material 15.0.0-rc.2
@schematics/angular 15.0.0-rc.3
rxjs 7.5.7
typescript
4.8.4
我的app.modules.ts:
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { MatChipsModule } from '@angular/material/chips';
@NgModule({
declarations: [
AppComponent
],
imports: [
MatChipsModule
],
exports: [
],
providers: [
],
bootstrap: [AppComponent],
entryComponents: [
]
})
export class AppModule` { }
我的成分是:
`<mat-chip-list>
<mat-chip>
Dog one
</mat-chip>
<mat-chip color="primary">
Dog two
</mat-chip>
<mat-chip color="accent">
Dog three
</mat-chip>
</mat-chip-list>`
和component.ts:
import { Component } from '@angular/core';
@Component({
selector: 'chips-example',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
})
export class AppComponent
{
}
发布于 2022-11-16 12:12:56
角材料v15切换到MDC基元件,这有一些打破的变化。当你发布这个问题的时候,角15还没有稳定的版本,但是现在它已经发布了。
有一个芯片迁移指南,它声明<mat-chip-list>
被移除并被三个替代组件所取代,很可能您想要使用<mat-chip-listbox>
。
或者,您可以通过导入v15来使用MatLegacyChipsModule
中的“旧”芯片实现。
发布于 2022-11-16 11:58:47
尝试在导入数组中包括BrowserModule、BrowserAnimationsModule,并在顶部定义导入。例如:从“@ BrowserModule /platform-browser”导入{ BrowserAnimationsModule },并从“@角/平台-浏览器/动画”导入{BrowserAnimationsModule};
https://stackoverflow.com/questions/74437274
复制相似问题