javascript - 在没有模块加载器的 ES6 模块系统(在浏览器中)中使用 rxjs
问题描述
我有来自 npm 的 rxjs v6。我想将它用作import
浏览器中使用 ES6 模块的一部分(Chrome v71)
从我在这里看到的https://github.com/ReactiveX/rxjs和我的一般情况来看,看起来我不能将它用作import
.
有没有什么小东西我可以把它包装起来(考虑 CDN 包),让我可以将它用作 ES6 模块系统的一部分,而不需要像 Webpack 这样的东西?
解决方案
https://github.com/ReactiveX/rxjs#cdn
CDN
For CDN, you can use unpkg:
https://unpkg.com/rxjs/bundles/rxjs.umd.min.js
The global namespace for rxjs is rxjs:
const { range } = rxjs;
const { map, filter } = rxjs.operators;
range(1, 200).pipe(
filter(x => x % 2 === 1),
map(x => x + x)
).subscribe(x => console.log(x));
推荐阅读
- html - 悬停不覆盖整个 li - css
- azure - Azure DevOps - 多租户数据库部署
- android - 添加到迁移后,当前架构中不存在类
- java - 如何在 Anylogic 中创建特定 Attractor 元素的函数作为 moveTo 块的目标
- git - 在不同的分支中识别相同的提交(不同的哈希,但相同的内容)?
- yaml - 使用 YAML 的 Azure 管道到管道触发器(跳过)
- wpf - Placing multiple canvases in a Grid
- ios - SwiftUI 使用 Stepper 动态添加/删除 TextField
- python - 如何测试列表中多个字典中的不同值和缺失键?
- sql - BigQuery 中的增量变量(以防万一)