MatToolbar与Angular 9一起使用时会引发错误 [英] MatToolbar throws error when using it with Angular 9

查看:225
本文介绍了MatToolbar与Angular 9一起使用时会引发错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Angular版本9.2.0

Angular version 9.2.0

当我将MatToolbarModule导入模块并在html模板中使用它时,会出现以下错误消息:

When I import the MatToolbarModule in a module and use it in the html template, then I get the following error message:

这很可能意味着ngcc未正确处理声明MatToolbarModule的库(@ angular/material/toolbar),或与Angular Ivy不兼容.检查是否有较新版本的库,如果有,则进行更新.还可以考虑与图书馆的作者进行核对,以查看该图书馆是否与Ivy兼容.

This likely means that the library (@angular/material/toolbar) which declares MatToolbarModule has not been processed correctly by ngcc, or is not compatible with Angular Ivy. Check if a newer version of the library is available, and update if so. Also consider checking with the library's authors to see if the library is expected to be compatible with Ivy.

8 export declare class MatToolbarModule {
                       ~~~~~~~~~~~~~~~~
src/app/angular-material.module.ts:53:14 - error NG6002: Appears in the NgModule.imports of ComponentsModule, but itself has errors

有人遇到同样的问题吗?

Does anyone face the same issue?

推荐答案

在package.json和npm install中添加以下特定配置.

Add below specific configuration in package.json and npm install.

{
  "scripts": {
    "postinstall": "ngcc"
  }
}

参考: https://angular.io/guide/ivy#speeding- up-ngcc-compilation

这篇关于MatToolbar与Angular 9一起使用时会引发错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆