【发布时间】:2017-06-15 01:33:10
【问题描述】:
我已经在我的 Angular 2 快速入门应用程序中安装了 Material Design 模块,但是当我在 app.module.ts 中导入模块时,应用程序似乎崩溃了。
这是在 app.module.ts 中设置的
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { MaterialModule } from '@angular/material';
import { MessagesComponent} from './messages-component';
import { AppComponent } from './app.component';
@NgModule({
imports: [ BrowserModule, MaterialModule ],
declarations: [ AppComponent, MessagesComponent ],
bootstrap: [ AppComponent ]
})
export class AppModule { }
我收到以下错误:
node_modules/@angular/material/typings/button/button.d.ts(40,22): error TS2420: Class 'MdButton' incorrectly implements interface 'CanDisabl
e'.
Property 'disabled' is missing in type 'MdButton'.
node_modules/@angular/material/typings/button/button.d.ts(40,39): error TS2507: Type '(new (...args: any[]) => CanDisable) & typeof MdButton
Base' is not a constructor function type.
node_modules/@angular/material/typings/checkbox/checkbox.d.ts(43,22): error TS2420: Class 'MdCheckbox' incorrectly implements interface 'Can
Disable'.
Property 'disabled' is missing in type 'MdCheckbox'.
node_modules/@angular/material/typings/checkbox/checkbox.d.ts(43,41): error TS2507: Type '(new (...args: any[]) => CanDisable) & typeof MdCh
eckboxBase' is not a constructor function type.
node_modules/@angular/material/typings/dialog/dialog-container.d.ts(2,32): error TS2307: Cannot find module '@angular/animations'.
node_modules/@angular/material/typings/menu/menu-animations.d.ts(1,42): error TS2307: Cannot find module '@angular/animations'.
node_modules/@angular/material/typings/radio/radio.d.ts(24,22): error TS2420: Class 'MdRadioGroup' incorrectly implements interface 'CanDisa
ble'.
Property 'disabled' is missing in type 'MdRadioGroup'.
node_modules/@angular/material/typings/radio/radio.d.ts(24,43): error TS2507: Type '(new (...args: any[]) => CanDisable) & typeof MdRadioGro
upBase' is not a constructor function type.
node_modules/@angular/material/typings/select/select-animations.d.ts(1,42): error TS2307: Cannot find module '@angular/animations'.
node_modules/@angular/material/typings/slide-toggle/slide-toggle.d.ts(14,22): error TS2420: Class 'MdSlideToggle' incorrectly implements int
erface 'CanDisable'.
Property 'disabled' is missing in type 'MdSlideToggle'.
node_modules/@angular/material/typings/slide-toggle/slide-toggle.d.ts(14,44): error TS2507: Type '(new (...args: any[]) => CanDisable) & typ
eof MdSlideToggleBase' is not a constructor function type.
node_modules/@angular/material/typings/slider/slider.d.ts(26,22): error TS2420: Class 'MdSlider' incorrectly implements interface 'CanDisabl
e'.
Property 'disabled' is missing in type 'MdSlider'.
node_modules/@angular/material/typings/slider/slider.d.ts(26,39): error TS2507: Type '(new (...args: any[]) => CanDisable) & typeof MdSlider
Base' is not a constructor function type.
node_modules/@angular/material/typings/snack-bar/snack-bar-container.d.ts(2,32): error TS2307: Cannot find module '@angular/animations'.
node_modules/@angular/material/typings/tabs/tab-body.d.ts(2,32): error TS2307: Cannot find module '@angular/animations'.
node_modules/@angular/material/typings/tooltip/tooltip.d.ts(2,32): error TS2307: Cannot find module '@angular/animations'.
以前有人遇到过这个问题吗?
【问题讨论】:
-
您是如何安装的以及您使用的是哪个版本的 Angular
-
两者的版本是什么?角度和md
-
MdModule 在 beta.3 中已被弃用。之后的任何版本都需要使用以下步骤进行设置,material.angular.io/guide/getting-started
-
Mike,我在 Github github.com/angular/quickstart 上克隆了 Angular 快速入门项目,所以无论 Angular 的版本是什么。至于 Material Design 版本,我使用 npm install --save @angular/material 安装。我没有指定任何特定版本。感谢您提供格式链接。卡坦
标签: angular typescript material-design