gpt4 book ai didi

javascript - Angular2 Material SnackBar 集成问题

转载 作者:行者123 更新时间:2023-12-03 05:22:06 24 4
gpt4 key购买 nike

我正在尝试集成Material Snackbar在我的 angular2 应用程序中。

我已经成功地从同一个库集成了 ProgressBar,但在使用 SnackBar 时遇到了错误。

以下是我集成 SnackBar

的方法

(相关)app.module.ts:

imports: [
BrowserModule,
HttpModule,
FormsModule,
CoreModule,
UsersModule,
AppRoutingModule,
MaterialModule.forRoot(),
],

(相关)app.component.ts:

  constructor(private route: ActivatedRoute,
private router: Router,
private snackBar: MdSnackBar,
private viewContainerRef: ViewContainerRef) {
}

// this method is bound to a simple button in template
showSnack() {
this.snackBar.open("Showing Snack", "Yayyy!");
}

单击 showSnack 按钮后,我收到此错误:

ORIGINAL EXCEPTION: view.animationContext.getAnimationPlayers is not a function

更详细的堆栈跟踪: enter image description here

最佳答案

我不知道为什么,但这是软件包版本的问题。

此问题出现在 Material 2.0.0-alpha.11-3 上,而我的 Angular 出现在 2.2.0 上。

将 Material 库更新到 2.0.0-beta.1 解决了我的问题。

关于javascript - Angular2 Material SnackBar 集成问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41332495/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com