当我运行具有以下规范的新 JSBIN 项目时:
- 使用标签:JavaScript、控制台
- 添加库:RxJS 5.0.0
然后在 JavaScript 区域运行以下代码块:
var observable = Rx.Observable.create(observer => {
setInterval(() => {
observer.onNext('This is the output of my async operation');
}, 2000);
});
observable.subscribe(response => console.log(response));
上述代码应在控制台区域呈现以下输出:
"This is the output of my async operation"
两秒钟后,控制台区域应该获得渲染:
"This is the output of my async operation"
但是,我收到以下错误:
"error"
-----------------------------
"ReferenceError: Rx is not defined
at yivicazake.js:3:4
at https://static.jsbin.com/js/prod/runner-3.39.12.min.js:1:13926
at https://static.jsbin.com/js/prod/runner-3.39.12.min.js:1:10855
这是我第一次使用 JSBIN 将 RxJS 作为库引入,我希望有人对这个特殊错误有过经验。