【发布时间】:2016-04-13 19:17:59
【问题描述】:
我正在尝试将 ng2-material 与 angular2 一起使用。
在尝试 Sidenav 组件时,我收到以下错误:
例外:TypeError: all_2.Media.hasMedia 不是 [hasMedia('gt-sm') 中的函数? 'side' : 'over' 在 AppComponent@17:32]
异常:错误:未捕获(承诺中):异常:TypeError:all_2.Media.hasMedia 不是 [hasMedia('gt-sm') 中的函数? 'side' : 'over' 在 AppComponent@17:32] 原始异常:TypeError:all_2.Media.hasMedia 不是函数 原始堆栈跟踪: TypeError: all_2.Media.hasMedia 不是函数 在 AppComponent.hasMedia (http://localhost:3000/app/app.component.js:67:40) 在 AbstractChangeDetector.ChangeDetector_AppComponent_0.detectChangesInRecordsInternal (viewFactory_AppComponent:114:31) 在 AbstractChangeDetector.detectChangesInRecords (http://localhost:3000/node_modules/angular2/bundles/angular2.dev.js:9609:14) 在 AbstractChangeDetector.runDetectChanges (http://localhost:3000/node_modules/angular2/bundles/angular2.dev.js:9592:12) 在 AbstractChangeDetector._detectChangesInViewChildren (http://localhost:3000/node_modules/angular2/bundles/angular2.dev.js:9671:14) 在 AbstractChangeDetector.runDetectChanges (http://localhost:3000/node_modules/angular2/bundles/angular2.dev.js:9596:12) 在 AbstractChangeDetector.detectChanges (http://localhost:3000/node_modules/angular2/bundles/angular2.dev.js:9581:12) 在 ChangeDetectorRef_.detectChanges (http://localhost:3000/node_modules/angular2/bundles/angular2.dev.js:5252:16) 在http://localhost:3000/node_modules/angular2/bundles/angular2.dev.js:12954:27 在 Array.forEach (本机) 错误上下文: [对象对象]
还有更多与all_2.Media.hasMedia相关的错误
这可能是导致它的代码
hasMedia(breakSize: string): boolean {
return Media.hasMedia(breakSize);
}
我已经关注instructions on ng2-material site 并且已经开始使用 ng2-material。
我应该如何解决这个问题?
【问题讨论】: