Angular Material: 我需要导入每个卡片组件吗
Angular Material: do I need to import every card component
如果我想使用 Material 卡片组件。
'mat-card-actions' is not a known element:
'mat-card-content' is not a known element:
'mat-card-title' is not a known element:
'mat-card-header' is not a known element:
'mat-card' is not a known element:
需要一一导入吗?
是的,为了 Angular 的 tree-shaking。
顺便说一句,你可以只在一个文件中创建一个数组并导入数组,然后将其传播到导入中:
FILE 1-- -- -- -- -- -- -
import {
lib
} from './file'
@NgModule()
export class App {
...
...
imports: [
...lib
]
}
FILE 2-- -- -- -- -- -- -
import { ...
} from '...'
export const lib = [All_Components]
只需要导入模块即可。
import {MatCardModule} from '@angular/material/card';
如果我想使用 Material 卡片组件。
'mat-card-actions' is not a known element:
'mat-card-content' is not a known element:
'mat-card-title' is not a known element:
'mat-card-header' is not a known element:
'mat-card' is not a known element:
需要一一导入吗?
是的,为了 Angular 的 tree-shaking。 顺便说一句,你可以只在一个文件中创建一个数组并导入数组,然后将其传播到导入中:
FILE 1-- -- -- -- -- -- -
import {
lib
} from './file'
@NgModule()
export class App {
...
...
imports: [
...lib
]
}
FILE 2-- -- -- -- -- -- -
import { ...
} from '...'
export const lib = [All_Components]
只需要导入模块即可。
import {MatCardModule} from '@angular/material/card';