首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >“‘mat芯片列表”不是已知的元素。

“‘mat芯片列表”不是已知的元素。
EN

Stack Overflow用户
提问于 2022-11-14 20:08:32
回答 2查看 1.2K关注 0票数 1

我在试着在组件里用垫片。在升级到角15之前,我的代码就可以工作了。

我正在导入模块,这似乎是一个常见的错误。

我想我已经按照医生的要求把所有的东西都包括了。

非常感谢提供的援助。谢谢

错误是:

代码语言:javascript
运行
复制
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.

版本信息是:

代码语言:javascript
运行
复制
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   
代码语言:javascript
运行
复制
               4.8.4

我的app.modules.ts:

代码语言:javascript
运行
复制
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` { }

我的成分是:

代码语言:javascript
运行
复制
`<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:

代码语言:javascript
运行
复制
   import { Component } from '@angular/core';

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

回答 2

Stack Overflow用户

发布于 2022-11-16 12:12:56

角材料v15切换到MDC基元件,这有一些打破的变化。当你发布这个问题的时候,角15还没有稳定的版本,但是现在它已经发布了。

有一个芯片迁移指南,它声明<mat-chip-list>被移除并被三个替代组件所取代,很可能您想要使用<mat-chip-listbox>

或者,您可以通过导入v15来使用MatLegacyChipsModule中的“旧”芯片实现。

票数 2
EN

Stack Overflow用户

发布于 2022-11-16 11:58:47

尝试在导入数组中包括BrowserModule、BrowserAnimationsModule,并在顶部定义导入。例如:从“@ BrowserModule /platform-browser”导入{ BrowserAnimationsModule },并从“@角/平台-浏览器/动画”导入{BrowserAnimationsModule};

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74437274

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档