![](/img/trans.png)
[英]error TS2305: Module “/node_modules/rxjs/Rx” has no exported member 'Subscribable'
[英]ERROR in node_modules/ng2-toastr/src/toast-container.component.d.ts(1,48): TS2305- /node_modules/@angular/core/core"' has no exported member
我有最新版本的"rxjs": "^6.0.0"
和@angular/cli": "~6.0.8"
当我运行ng serve
我收到以下编译错误-
ERROR in node_modules/ng2-toastr/src/toast-container.component.d.ts(1,48):
/node_modules/@angular/core/core"' has no exported member'AnimationTransitionEvent'.
imported toastermodule in the below format in my app.module.ts
import {ToastrModule} from 'ngx-toastr';
还收到以下错误
error TS2305: Module '"C:/Users/user1/Sublime Text 3/NodeJS/groupchat-application/node_modules/rxjs/Observable"' has no exported member 'Observable'.
node_modules/rxjs/Observable.d.ts(1,15): error TS2307: Cannot find module 'rxjs-compat/Observable'.
imported as below in My service.ts
import { Observable, of} from "rxjs";
请指导如何进行
Use **ngx-toastr**
**steps to follow**
Install dependencies
1)npm install ngx-toastr --save
2)npm install @angular/animations --save
3)Add CSS to your angular.json file
"styles": [
"styles.scss",
"node_modules/ngx-toastr/toastr.css" // try adding '../' if you're using angular cli before 6
]
4)Add toastr module to your app.module.ts
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { ToastrModule } from 'ngx-toastr';
@NgModule({
imports: [BrowserAnimationsModule,
ToastrModule.forRoot()
})
5) Add toastr service to your desired component
import { ToastrService } from 'ngx-toastr';
@Component({...})
export class YourComponent {
constructor(private toastr: ToastrService) {}
showSuccess() {
this.toastr.success('Hello world!', 'Toastr fun!');
}
}
您使用 "rxjs": "^6.0.0" 和 ng2-toastr: 使用低于 6.0.0 的 rxjs,因此存在兼容性问题。 您有两种选择:
rxjs-compat与rxjs 6.0.0
否则使用ngx-toasta [链接]
编辑:由于 angular 的更新及其依赖性不同步,如果您使用的是 angular material 6+,那么您可以选择 @angular/material Snackbar,它与最新版本的 Angular 兼容更好。
我能够使用解决这个问题
npm install ng6-toastr-notifications --save
提供了一个很好的文档链接。我会为您提供链接
这个问题是由于 toastr 和动画与你的角度版本兼容!
ngx-toastr Angular
6.5.0 4.x
8.10.2 5.x
10.1.0 8.x 7.x 6.x
11.3.3 8.x
12.1.0 9.x
current >= 10.x
为您的情况尝试这些版本:
如果您的项目中有 toastr 和动画,请先卸载它们,然后运行它们:
npm 安装 ngx-toastr@10.0.4 --保存
npm install @angular/animations@8.2.14 --保存
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.