You need to enable JavaScript to run this app. 升级Angular 15后'mat-chip-list'未知元素错误求助
优惠活动
大模型
产品
解决方案
定价
更多

升级Angular 15后'mat-chip-list'未知元素错误求助

解决Angular 15中'mat-chip-list'未识别的问题

问题分析

你已导入MatChipsModule但仍报错,核心原因是根模块缺少必要的基础配置模块:

  • Angular根模块必须导入BrowserModule以启用浏览器环境下的核心功能
  • Angular Material组件依赖BrowserAnimationsModule完成组件初始化

解决方案

修改app.module.ts,添加缺失的基础模块:

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { AppComponent } from './app.component';
import { MatChipsModule } from '@angular/material/chips';

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

验证步骤

  1. 保存修改后的app.module.ts
  2. 重启Angular开发服务器(若已启动)
  3. 检查组件模板是否正常渲染mat-chip-list与mat-chip组件

补充说明

Angular 15的Material Chips模块结构未发生变更,MatChipsModule仍包含mat-chip-list和mat-chip组件,但根模块必须具备完整的基础配置,Angular才能正确识别并加载这些组件。

内容的提问来源于stack exchange,提问作者Ian

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.12 14:20:34