gpt4 book ai didi

polyfills - 如何包含 yaffle 事件源 polyfill

转载 作者:行者123 更新时间:2023-12-02 03:11:26 28 4
gpt4 key购买 nike

https://github.com/Yaffle/EventSource

我使用上面的是因为我想获得在 IE11 中工作的 promise ,我已经用 npm 安装了它但不确定我应该如何实现它。我在我的 js 文件中尝试了 import event-source-polyfill 但这也没有用。文档说只是运行构建,但如果我已经在 node_modules/event-source-polyfill 目录中看到 min.js 文件,那么这样做的目的是什么?如何实际包含它?

最佳答案

要找到您的根本问题,您可能需要像 https://github.com/stefanpenner/es6-promise 这样的东西如果你想要 Promises 的 polyfill。

对于 Yaffle/EventSource,这是一个 polyfill EventSource .您可以通过将 javascript 的路径添加到您的客户端前端(即您的 HTML 网页)来确保其正常工作,如下所示:

<script src="./node_modules/event-source-polyfill/src/eventsource.min.js"></script>

您不需要构建它,除非您想确保生成的 javascript (eventsource.min.js) 是准确的。

关于polyfills - 如何包含 yaffle 事件源 polyfill,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39698074/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com