首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法读取未定义的ngx-toastr属性“push”中的错误

无法读取未定义的ngx-toastr属性“push”中的错误
EN

Stack Overflow用户
提问于 2020-03-06 13:43:27
回答 2查看 328关注 0票数 0

在我的应用程序中,我试图集成托斯特尔

作为其中的一部分,我已经整合了package.json和angular.json。到目前为止,当我集成worked.but时,应用程序app.module.ts

app.module.ts

代码语言:javascript
复制
  imports: [
    BrowserModule,
    AppRoutingModule,
    HttpClientModule,
    FormsModule,
    ReactiveFormsModule,
    ToastrModule.forRoot({
      timeOut: 1000,
      positionClass: 'toast-bottom-right'
    })
  ],
export class AppModule { }

我得到了以下错误。

代码语言:javascript
复制
@import must precede all other statements (besides @charset)

WARNING in Entry point 'ngx-toastr' contains deep imports into 'C:/Users/angular-frontend/node_modules/@angular/compiler/src/core'. This is probably not a problem, but may cause the compilation of entry points to be out of order.

ERROR in Cannot read property 'push' of undefined
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2020-03-09 07:34:34

我已经解决了这个问题

ng update @angular/cli @angular/core --allow-dirty

票数 1
EN

Stack Overflow用户

发布于 2020-03-06 13:57:28

用@NgModule装饰器来装饰您的进口商品:

代码语言:javascript
复制
import {ToastrModule} from 'ngx-toastr';
@NgModule({
  imports: [
    BrowserModule,
    AppRoutingModule,
    HttpClientModule,
    FormsModule,
    ReactiveFormsModule,
    ToastrModule.forRoot({
      timeOut: 1000,
      positionClass: 'toast-bottom-right'
    })
  ],
})
export class AppModule {}

请参阅https://angular.io/guide/architecture-modules

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60565327

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档