Angular 角度材料配置错误和警告请帮我弄清楚
使用cli的角度材质2。当我安装@angular/material并将其包含在app.module中时,编译器将通过3个警告进行编译 我所做的 npm安装——节省角度/材料 其他进口Angular 角度材料配置错误和警告请帮我弄清楚,angular,angular-material,Angular,Angular Material,使用cli的角度材质2。当我安装@angular/material并将其包含在app.module中时,编译器将通过3个警告进行编译 我所做的 npm安装——节省角度/材料 其他进口 import { MaterialModule } from '@angular/material'; @NgModule({ declarations: [ AppComponent ], imports: [ MaterialModule.forRoot(),other imp
import { MaterialModule } from '@angular/material';
@NgModule({
declarations: [
AppComponent
],
imports: [
MaterialModule.forRoot(),other imports...
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
附加设置
styles.css
@import '~@angular/material/core/theming/prebuilt/deeppurple-amber.css';
index.html
<script src="https://ajax.googleapis.com/ajax/libs/hammerjs/2.0.8/hammer.min.js"></script>
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
运行时出错
Uncaught TypeError:无法读取未定义的属性“prototype”
at__扩展(快餐店容器.js:4)
在快餐店集装箱。js:28
反对。(快餐店容器.js:122)
在需要的网页包(引导程序9ff6af8…:52)
反对。(快餐店-ref.js:70)
在需要的网页包(引导程序9ff6af8…:52)
反对。(menu.js:40)
在需要的网页包(引导程序9ff6af8…:52)
反对。(icon.js:264)
在需要的网页包(引导程序9ff6af8…:52)
从官方网站,您应该导入每个模块。我在开发过程中一次导入所有内容,但没有.forRoot(),并且工作正常:
imports: [
MaterialModule,
],
Uncaught TypeError: Cannot read property 'prototype' of undefined
at __extends (snack-bar-container.js:4)
at snack-bar-container.js:28
at Object.<anonymous> (snack-bar-container.js:122)
at __webpack_require__ (bootstrap 9ff6af8…:52)
at Object.<anonymous> (snack-bar-ref.js:70)
at __webpack_require__ (bootstrap 9ff6af8…:52)
at Object.<anonymous> (menu.js:40)
at __webpack_require__ (bootstrap 9ff6af8…:52)
at Object.<anonymous> (icon.js:264)
at __webpack_require__ (bootstrap 9ff6af8…:52)
imports: [
MaterialModule,
],