我对 rxjs 很陌生,请耐心等待。
例如在本教程中http://blog.angular-university.io/how-to-build-angular2-apps-using-rxjs-observable-data-services-pitfalls-to-avoid/ http://blog.angular-university.io/how-to-build-angular2-apps-using-rxjs-observable-data-services-pitfalls-to-avoid/但我在 ng-book 中看到了相同的代码
我可以看到
let subject = new Rx.Subject();
subject.subscribe(value => console.log('Received new subject value: '))
subject.next(newValue);
但如果我将代码放入浏览器中,我就会得到
sobject.next 不是一个函数
所以如果我看一下医生https://github.com/Reactive-Extensions/RxJS/blob/master/doc/gettingstarted/subjects.md https://github.com/Reactive-Extensions/RxJS/blob/master/doc/gettingstarted/subjects.md
var subject = new Rx.Subject();
subject.subscribe(value => console.log('Received new subject value: ',value))
subject.onNext(2);
你能解释一下为什么要使用教程和本书吗
接下来正在使用吗?我缺少什么?
看来您使用了错误的 rxjs 版本(4.x)。 Angular2 使用 rxjs 5https://github.com/ReactiveX/rxjs/ https://github.com/ReactiveX/rxjs/
也可以看看http://reactivex.io/rxjs/ http://reactivex.io/rxjs/
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)