TS2305:模块'./@angular/material/material'没有导出的成员'MaterialModule' [英] TS2305: Module './@angular/material/material' has no exported member 'MaterialModule'

查看:74
本文介绍了TS2305:模块'./@angular/material/material'没有导出的成员'MaterialModule'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我相信由于材料模块从版本10更新到版本12引起了此错误,但是我没有找到解决此问题的方法.当前材料模块版本:

I believe this error has aroused due to an update of the material module from version 10 to 12, but I have found no solution to this issue. current material module version:

"@angular/material": "^2.0.0-beta.12"

在package-lock.json中:

in package-lock.json:

"@angular/material": {
  "version": "2.0.0-beta.12",
  "resolved": "https://registry.npmjs.org/@angular/material/-/material-2.0.0-beta.12.tgz",
  "integrity": "sha1-cbbQt7AhiR5dDjaIwdS9eMdFf1g=",
  "requires": {
    "tslib": "1.8.0"
  }
},

由于性能原因,

推荐答案

MaterialModule 已与棱角材质版本 2.0.0-beta.11 删除(请参阅他们的更改日志).从beta 11开始,您将必须分别导入所需的每个材料模块.当然,您还可以创建一个专用模块,将所有材料模块放入其中,并将该模块导入到根模块(或将要使用的任何模块)中.

MaterialModule has been removed with angular material version 2.0.0-beta.11 for performance reasons (see their changelog). From beta 11 you'll have to import each material module you need separately. Of course you can also create a dedicated module where you'd put all your material modules in and import the module into your root module (or whatever module you will be using it).

有关更多详细信息,您可能希望参考其路线图并引用:

For more details you might want to refer to their roadmap as well, quote:

我们发现,就目前世界上摇树的状况而言,使用像 MaterialModule 这样的汇总 NgModule 会导致工具无法消除不使用的组件的代码.

We've found that, with the current state of tree-shaking in the world, that using an aggregate NgModule like MaterialModule leads to tools not being able to eliminate code for components that aren't used.

为了确保用户最终获得尽可能小的代码大小,我们不建议使用 MaterialModule ,该代码将在后续版本中删除.

In order to ensure that users end up with the smallest code size possible, we're deprecating MaterialModule, to be removed in the a subsequent release.

要替换 MaterialModule ,用户可以创建自己的"Material"文件.应用程序中的模块(例如 GmailMaterialModule ),该模块仅导入应用程序中实际使用的组件集.

To replace MaterialModule, users can create their own "Material" module within their application (e.g., GmailMaterialModule) that imports only the set of components actually used in the application.

这篇关于TS2305:模块'./@angular/material/material'没有导出的成员'MaterialModule'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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