简体   繁体   English

将 Angular Material 迁移到 v12 不会删除旧的导入语法

[英]Migrating Angular Material to v12 does not remove old import syntax

I upgraded my Angular app to v12, and since I am using Material, I upgraded Material as well.我将我的 Angular 应用程序升级到 v12,因为我使用的是 Material,所以我也升级了 Material。

In the v12 announcement article they said that Material now expose new @use syntax and upgrade should migrate syntax automatically.v12 公告文章中,他们说 Material 现在公开了新的@use语法,并且升级应该自动迁移语法。 They also added code example of the new VS old syntax .他们还添加了新 VS 旧语法的代码示例

So basically @import '~@angular/material/theming;所以基本上@import '~@angular/material/theming; should be replaced with @use '~@angular/material' as mat;应替换为@use '~@angular/material' as mat; . .

When I checked changes after upgrade finished successfully, I noticed that in the styles.scss the @use '~@angular/material' as mat;当我在升级成功完成后检查更改时,我注意到在styles.scss@use '~@angular/material' as mat; line were added, BUT @import '~@angular/material/theming;添加了行,但是@import '~@angular/material/theming; line was NOT removed .线没有被删除 So now, I have both @use and import in my styles.scss file.所以现在,我的styles.scss文件中有@useimport

Should I remove @import '~@angular/material/theming;我应该删除@import '~@angular/material/theming; ? ? As I understand, it will import the same thing twice, so it can only increase the size of the file.据我了解,它会导入相同的东西两次,所以它只能增加文件的大小。

As announced here the new @use is an improvement on how often scss files are imported.正如这里所宣布的,新的@use是对 scss 文件导入频率的改进。 Basically both @import and @use work.基本上@import@use工作。 BUT @use has potentially a better performance.但是@use可能有更好的性能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Angular 从 v12 迁移到 v14 - Angular migration from v12 to v14 "Angular v12 组件样式文件不编译tailwindcss @apply" - Angular v12 Component style files not compiling tailwindcss @apply angular v12 中的嵌套表单控制问题 - Nested form control issue in angular v12 从 TSLint 迁移到 ESLint 和 ESLint 导致解析错误:Unexpected token &lt; and does not check.ts files in angular v12 - Migrated from TSLint to ESLint and ESLint causes parsing error: Unexpected token < and does not check .ts files in angular v12 升级 angular v12 到 v13 时出现找不到模块错误 - Getting Module not found error when upgrade angular v12 to v13 将 Angular v12 升级到 v13 后未捕获 TypeError - Uncaught TypeError after upgrading Angular v12 to v13 iOS v12 Https请求错误 - iOS v12 Https requests errors Angular (v12) 检测浏览器触发的导航以发送 Google 分析调用 - Angular (v12) detect browser triggered navigation to send Google analytics call 如何在 Angular CLI V12 中为 div 制作变量 css 高度 - How to make a variable css height for a div in Angular CLI V12 Angular Karma:从 Angular v8 升级到 v12 后,await fixture.whenStable 总是超时 - Angular Karma: await fixture.whenStable always times out after upgrade from Angular v8 to v12
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM